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
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • 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
  • cApiImageCheckImageEditingPossibility
  • 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
  • conGetUniqueArticleUrlname
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsArticleUrlnameUnique
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeInlineScript
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSetStartArticle
  • consoleLog
  • 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
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getJsHelpContext
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParentAreaId
  • getRightsList
  • 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
  • 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
  • strCheckAlias
  • 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
  • Function
  • Tree
  • Deprecated
  • Todo
   1: <?php
   2: 
   3: /**
   4:  * This file contains the CONTENIDO upload functions.
   5:  *
   6:  * @package Core
   7:  * @subpackage Backend
   8:  * @author Jan Lengowski
   9:  * @author Timo Trautmann
  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: cInclude('includes', 'functions.file.php');
  19: 
  20: /**
  21:  * Function reduces long path names and creates a dynamic tooltipp which shows
  22:  * the full path name on mouseover
  23:  *
  24:  * @param string $sDisplayPath
  25:  *         Original filepath
  26:  * @param int $iLimit
  27:  *         Limit of chars which were displayed directly.
  28:  *         If the path string is shorter there will be no tooltip
  29:  * @return string
  30:  *         Contains short path name and tooltipp if necessary
  31:  */
  32: function generateDisplayFilePath($sDisplayPath, $iLimit) {
  33:     $sDisplayPath = (string) $sDisplayPath;
  34:     $iLimit = (int) $iLimit;
  35: 
  36:     if (cString::getStringLength($sDisplayPath) > $iLimit) {
  37:         $sDisplayPathShort = cString::trimHard($sDisplayPath, $iLimit);
  38: 
  39:         $sTooltippString = '';
  40:         $iCharcount = 0;
  41: 
  42:         $aPathFragments = explode('/', $sDisplayPath);
  43: 
  44:         foreach ($aPathFragments as $sFragment) {
  45:             if ($sFragment != '') {
  46:                 if (cString::getStringLength($sFragment) > ($iLimit - 5)) {
  47:                     $sFragment = cString::trimHard($sFragment, $iLimit);
  48:                 }
  49: 
  50:                 if ($iCharcount + cString::getStringLength($sFragment) + 1 > $iLimit) {
  51:                     $sTooltippString .= '<br>' . $sFragment . '/';
  52:                     $iCharcount = cString::getStringLength($sFragment);
  53:                 } else {
  54:                     $iCharcount = $iCharcount + 1 + cString::getStringLength($sFragment);
  55:                     $sTooltippString .= $sFragment . '/';
  56:                 }
  57:             }
  58:         }
  59: 
  60:         $sDisplayPath = '<span title="' . $sTooltippString . '" class="tooltip">' . $sDisplayPathShort . '</span>';
  61:     }
  62:     return $sDisplayPath;
  63: }
  64: 
  65: /**
  66:  * Returns array structure of passed directory.
  67:  * Parses the directory recursively and
  68:  * collects informations about found subdirectories.
  69:  *
  70:  * @deprecated [2015-05-21]
  71:  *         This method is no longer supported (no replacement) *
  72:  *
  73:  * @param string $sCurrentDir
  74:  *         Directory to parse
  75:  * @param string $sStartDir
  76:  *         Start directory. Will be used by recursion.
  77:  * @param array  $aFiles
  78:  *         Files array structure. Will be used by recursion.
  79:  * @param int    $iDepth
  80:  *         Nesting depth of found files. Will be used by recursion.
  81:  * @param string $sPathString
  82:  *         Path used to create full path to files. Will be used by recursion.
  83:  *
  84:  * @return array
  85:  *         Indexed arraay containing assoziative directory informations
  86:  *
  87:  * @throws cDbException
  88:  * @throws cException
  89:  * @throws cInvalidArgumentException
  90:  */
  91: function uplDirectoryListRecursive($sCurrentDir, $sStartDir = '', $aFiles = array(), $iDepth = -1, $sPathString = '') {
  92:     cDeprecated('This method is deprecated and is not needed any longer');
  93: 
  94:     $iDepth++;
  95: 
  96:     $aDirsToExclude = uplGetDirectoriesToExclude();
  97: 
  98:     // remember where we started from
  99:     if (empty($sStartDir)) {
 100:         $sStartDir = $sCurrentDir;
 101:     }
 102: 
 103:     if (chdir($sCurrentDir) == false) {
 104:         return $aFiles;
 105:     }
 106: 
 107:     // list the files in the dir
 108:     $aCurrentFiles = array();
 109:     if (false === ($handle = cDirHandler::read('.', false, true))) {
 110:         return $aFiles;
 111:     }
 112:     foreach ($handle as $file) {
 113:         if (!in_array(cString::toLowerCase($file), $aDirsToExclude)) {
 114:             $aCurrentFiles[] = $file;
 115:         }
 116:     }
 117:     sort($aCurrentFiles);
 118: 
 119:     foreach ($aCurrentFiles as $file) {
 120:         $sFilePathName = getcwd() . '/' . $file;
 121:         if ((filetype($sFilePathName) == 'dir') && (opendir($sFilePathName) !== false)) {
 122:             $_aFile = array(
 123:                     'name' => $file,
 124:                     'depth' => $iDepth,
 125:                     'pathstring' => $sPathString . $file . '/'
 126:             );
 127: 
 128:             $aFiles[] = $_aFile;
 129: 
 130:             $aFiles = uplDirectoryListRecursive($sFilePathName, getcwd(), $aFiles, $iDepth, $_aFile['pathstring']);
 131:         }
 132:     }
 133: 
 134:     chdir($sStartDir);
 135:     return $aFiles;
 136: }
 137: 
 138: /**
 139:  * Checks if passed upload directory contains at least one file or directory
 140:  *
 141:  * @todo Function name is misleading, should be renamed to uplIsEmpty
 142:  * @param string $sDir
 143:  * @return bool
 144:  */
 145: function uplHasFiles($sDir) {
 146: 
 147:     $client = cRegistry::getClientId();
 148:     $cfgClient = cRegistry::getClientConfig($client);
 149: 
 150:     $handle = cDirHandler::read($cfgClient['upl']['path'] . $sDir);
 151: 
 152:     if (!$handle) {
 153:         return false;
 154:     }
 155: 
 156:     $bHasContent = false;
 157:     if (is_dir($cfgClient['upl']['path'] . $sDir)) {
 158:         foreach ($handle as $sDirEntry) {
 159:             if (cFileHandler::fileNameIsDot($sDirEntry) === false) {
 160:                 $bHasContent = true;
 161:                 break;
 162:             }
 163:         }
 164:     }
 165:     return $bHasContent;
 166: }
 167: 
 168: /**
 169:  * Checks if passed upload directory contains at least one directory
 170:  *
 171:  * @param string $sDir
 172:  * @return bool
 173:  */
 174: function uplHasSubdirs($sDir) {
 175: 
 176:     $client = cRegistry::getClientId();
 177:     $cfgClient = cRegistry::getClientConfig($client);
 178: 
 179:     $handle = cDirHandler::read($cfgClient['upl']['path'] . $sDir);
 180:     if (!$handle) {
 181:         return false;
 182:     }
 183: 
 184:     $bHasSubdir = false;
 185:     if (is_dir($cfgClient['upl']['path'] . $sDir)) {
 186:         foreach ($handle as $sDirEntry) {
 187:             if (cFileHandler::fileNameIsDot($sDirEntry) === false) {
 188:                 $bHasSubdir = true;
 189:                 break;
 190:             }
 191:         }
 192:     }
 193: 
 194:     return $bHasSubdir;
 195: }
 196: 
 197: /**
 198:  * Sync database contents with directory and vice versa.
 199:  * - Removes all db entries pointing to non existing directories
 200:  * - Removes all db entries pointing to non existing upload files
 201:  * - Syncs found files in passed path with the database
 202:  *
 203:  * @param string $sPath
 204:  *         Specifies the path to scan
 205:  *
 206:  * @throws cDbException
 207:  * @throws cException
 208:  * @throws cInvalidArgumentException
 209:  */
 210: function uplSyncDirectory($sPath) {
 211: 
 212:     $cfg = cRegistry::getConfig();
 213:     $db = cRegistry::getDb();
 214:     $client = cRegistry::getClientId();
 215:     $cfgClient = cRegistry::getClientConfig($client);
 216: 
 217:     if (cApiDbfs::isDbfs($sPath)) {
 218:         uplSyncDirectoryDBFS($sPath);
 219:         return;
 220:     }
 221: 
 222:     $oUploadsColl = new cApiUploadCollection();
 223: 
 224:     // get current upload directory, it's subdirectories and remove all database
 225:     // entries pointing to a non existing upload directory on the file system
 226:     $sql = 'SELECT DISTINCT(dirname) AS dirname FROM ' . $cfg['tab']['upl'] . ' WHERE ' . 'idclient=' . cSecurity::toInteger($client) . ' AND dirname LIKE "' . $db->escape($sPath) . '%"';
 227:     $db->query($sql);
 228:     while ($db->nextRecord()) {
 229:         $sCurrDirname = $db->f('dirname');
 230:         $sSubDir = cString::getPartOfString($sCurrDirname, cString::getStringLength($sPath));
 231:         if (cString::countSubstring($sSubDir, '/') <= 1 && !cApiDbfs::isDbfs($sCurrDirname)) {
 232:             // subdirectory is a direct descendant, process this directory too
 233:             $sFullPath = $cfgClient['upl']['path'] . $sCurrDirname;
 234:             if (!is_dir($sFullPath)) {
 235:                 $oUploadsColl->deleteByDirname($sCurrDirname);
 236:             }
 237:         }
 238:     }
 239: 
 240:     // delete all db entries related to current directory without existing file
 241:     // on file system
 242:     $oUploadsColl->select("dirname='" . $oUploadsColl->escape($sPath) . "' AND idclient=" . (int) $client);
 243:     while (($oUpload = $oUploadsColl->next()) !== false) {
 244:         if (!cFileHandler::exists($cfgClient['upl']['path'] . $oUpload->get('dirname') . $oUpload->get('filename'))) {
 245:             $oUploadsColl->delete($oUpload->get('idupl'));
 246:         }
 247:     }
 248: 
 249:     // sync all files in current directory with database
 250:     $sFullPath = $cfgClient['upl']['path'] . $sPath;
 251:     if (is_dir($sFullPath)) {
 252:         $aDirsToExclude = uplGetDirectoriesToExclude();
 253:         if (false !== ($handle = cDirHandler::read($sFullPath))) {
 254:             foreach ($handle as $file) {
 255:                 if (!in_array(cString::toLowerCase($file), $aDirsToExclude)) {
 256:                     cDebug::out($sPath . "::" . $file);
 257:                     $oUploadsColl->sync($sPath, $file);
 258:                 }
 259:             }
 260:         }
 261:     }
 262: }
 263: 
 264: /**
 265:  * Sync database contents with DBFS
 266:  *
 267:  * @param string $sPath
 268:  *         Specifies the path to scan
 269:  *
 270:  * @throws cDbException
 271:  * @throws cException
 272:  * @throws cInvalidArgumentException
 273:  */
 274: function uplSyncDirectoryDBFS($sPath) {
 275: 
 276:     $client = cRegistry::getClientId();
 277: 
 278:     $oUploadsColl = new cApiUploadCollection();
 279:     $oPropertiesColl = new cApiPropertyCollection();
 280:     $oDBFSColl = new cApiDbfsCollection();
 281: 
 282:     if ($oDBFSColl->dirExists($sPath)) {
 283:         $sStripPath = cApiDbfs::stripPath($sPath);
 284:         $oDBFSColl->select("dirname = '$sStripPath'");
 285:         while (($oFile = $oDBFSColl->next()) !== false) {
 286:             if ($oFile->get('filename') != '.') {
 287:                 $oUploadsColl->sync($sPath . "/", $oFile->get('filename'));
 288:             }
 289:         }
 290:     }
 291: 
 292:     $oUploadsColl->select("dirname='$sPath/' AND idclient='$client'");
 293:     while (($oUpload = $oUploadsColl->next()) !== false) {
 294:         if (!$oDBFSColl->fileExists($oUpload->get('dirname') . $oUpload->get('filename'))) {
 295:             $oUploadsColl->delete($oUpload->get("idupl"));
 296:         }
 297:     }
 298: 
 299:     $oPropertiesColl->select("idclient='$client' AND itemtype='upload' AND type='file' AND itemid LIKE '" . $sPath . "%'");
 300:     while (($oProperty = $oPropertiesColl->next()) !== false) {
 301:         if (!$oDBFSColl->fileExists($oProperty->get('itemid'))) {
 302:             $oPropertiesColl->delete($oProperty->get('idproperty'));
 303:         }
 304:     }
 305: 
 306: }
 307: 
 308: /**
 309:  * Creates a upload directory, either in filesystem or in dbfs.
 310:  *
 311:  * @param string $sPath
 312:  *         Path to directory to create.
 313:  *         Either path from client upload directory or a dbfs path.
 314:  * @param string $sName
 315:  *         Name of directory to create
 316:  *
 317:  * @return string|void
 318:  *         value of filemode as string ('0702') or nothing
 319:  * 
 320:  * @throws cDbException
 321:  * @throws cException
 322:  * @throws cInvalidArgumentException
 323:  */
 324: function uplmkdir($sPath, $sName) {
 325: 
 326:     $client = cRegistry::getClientId();
 327:     $cfgClient = cRegistry::getClientConfig($client);
 328:     $action = cRegistry::getAction();
 329: 
 330:     // Check DB filesystem
 331:     if (cApiDbfs::isDbfs($sPath)) {
 332:         $sPath = cApiDbfs::stripPath($sPath);
 333:         $sFullPath = $sPath . '/' . $sName . '/.';
 334: 
 335:         $dbfs = new cApiDbfsCollection();
 336:         $dbfs->create($sFullPath);
 337:         return;
 338:     }
 339: 
 340:     // Check directory name
 341:     $dName = uplCreateFriendlyName($sName);
 342:     $dName = strtr($dName, "'", '.');
 343:     if ($dName != $sName) {
 344:         $action = 'upl_mkdir';
 345:         return '0703';
 346:     }
 347: 
 348:     // Checks right to create a new directory
 349:     $motherDir = $cfgClient['upl']['path'] . $sPath;
 350:     if (cDirHandler::isCreatable($motherDir) === false) {
 351:         $action = 'upl_mkdir';
 352:         return '0704';
 353:     }
 354: 
 355:     // Check dir or create new
 356:     $dPath = $cfgClient['upl']['path'] . $sPath . $dName;
 357:     if (cDirHandler::read($dPath) === false) {
 358:         // Create new dir
 359:         return cDirHandler::create($dPath);
 360:     } else {
 361:         // Directory already exists
 362:         $action = 'upl_mkdir';
 363:         return '0702';
 364:     }
 365: }
 366: 
 367: /**
 368:  * Renames a upload directory, updates all found upoad files containing the old
 369:  * directory name and updates also all entries in propertoes table related to
 370:  * affected upload files.
 371:  *
 372:  * @param string $sOldName
 373:  * @param string $sNewName
 374:  * @param string $sParent
 375:  * 
 376:  * @throws cException
 377:  *         if the upload path can not be renamed
 378:  */
 379: function uplRenameDirectory($sOldName, $sNewName, $sParent) {
 380: 
 381:     $client = cRegistry::getClientId();
 382:     $cfgClient = cRegistry::getClientConfig($client);
 383: 
 384:     // rename directory
 385:     $sOldUplPath = $cfgClient['upl']['path'] . $sParent . $sOldName;
 386:     $sNewUplPath = $cfgClient['upl']['path'] . $sParent . $sNewName . '/';
 387:     if (!$bResult = rename($sOldUplPath, $sNewUplPath)) {
 388:         throw new cException("Couldn't rename upload path {$sOldUplPath} to {$sNewUplPath}");
 389:     }
 390: 
 391:     // fetch all directory strings starting with the old path, and replace them
 392:     // with the new path
 393:     $oUploadColl = new cApiUploadCollection();
 394:     $oUploadColl->select("idclient=" . cSecurity::toInteger($client) . " AND dirname LIKE '" . $oUploadColl->escape($sParent . $sOldName) . "%'");
 395:     while (($oUpload = $oUploadColl->next()) !== false) {
 396:         $sDirName = $oUpload->get('dirname');
 397:         $sJunk = cString::getPartOfString($sDirName, cString::getStringLength($sParent) + cString::getStringLength($sOldName));
 398:         $sNewName2 = $sParent . $sNewName . $sJunk;
 399:         $oUpload->set('dirname', $sNewName2, false);
 400:         $oUpload->store();
 401:     }
 402: 
 403:     // update all upload item properties starting with the old path, replace
 404:     // itemid with the new path
 405:     $oPropertyColl = new cApiPropertyCollection();
 406:     $oPropertyColl->select("idclient=" . (int) $client . " AND itemtype='upload' AND type='file' AND itemid LIKE '" . $oPropertyColl->escape($sParent . $sOldName) . "%'");
 407:     while (($oProperty = $oPropertyColl->next()) !== false) {
 408:         $sDirName = $oProperty->get('itemid');
 409:         $sJunk = cString::getPartOfString($sDirName, cString::getStringLength($sParent) + cString::getStringLength($sOldName));
 410:         $sNewName2 = $sParent . $sNewName . $sJunk;
 411:         $oProperty->set('itemid', $sNewName2, false);
 412:         $oProperty->store();
 413:     }
 414: }
 415: 
 416: /**
 417:  * Parses passed directory recursively and stores some properties in TreeItem
 418:  *
 419:  * @param string   $sDirectory
 420:  * @param TreeItem $oRootItem
 421:  * @param int      $iLevel
 422:  * @param string   $sParent
 423:  * @param int      $iRenameLevel
 424:  *
 425:  * @return array
 426:  *         List of invalid directories
 427:  * 
 428:  * @throws cException
 429:  */
 430: function uplRecursiveDirectoryList($sDirectory, TreeItem $oRootItem, $iLevel, $sParent = '', $iRenameLevel = 0) {
 431:     $aInvalidDirectories = array();
 432: 
 433:     if (true === is_dir($sDirectory)) {
 434:         $aDirsToExclude = uplGetDirectoriesToExclude();
 435: 
 436:         $aFiles = array();
 437: 
 438:         // list the files in the dir
 439:         foreach (cDirHandler::read($sDirectory, false, true) as $key => $file) {
 440:             if (!in_array(cString::toLowerCase($file), $aDirsToExclude)) {
 441:                 if (cString::findFirstPos($file, ".") === 0) {
 442:                     continue;
 443:                 }
 444:                 if (@chdir($sDirectory . $file . '/')) {
 445:                     if (uplCreateFriendlyName($file) == $file) {
 446:                         $aFiles[] = $file;
 447:                     } else {
 448:                         if ($_GET['force_rename'] == 'true') {
 449:                             if ($iRenameLevel == 0 || $iRenameLevel == $iLevel) {
 450:                                 uplRenameDirectory($file, uplCreateFriendlyName($file), $sParent);
 451:                                 $iRenameLevel = $iLevel;
 452:                                 $aFiles[] = uplCreateFriendlyName($file);
 453:                             } else {
 454:                                 $aInvalidDirectories[] = $file;
 455:                             }
 456:                         } else {
 457:                             $aInvalidDirectories[] = $file;
 458:                         }
 459:                     }
 460:                 }
 461:             }
 462:         }
 463: 
 464:         sort($aFiles);
 465:         foreach ($aFiles as $key => $file) {
 466:             $oItem = new TreeItem($file, $sDirectory . $file . '/', true);
 467:             $oItem->setCustom('level', $iLevel);
 468:             $oItem->setCustom('lastitem', ($key == count($aFiles) - 1));
 469:             $oItem->setCustom('parent', $sDirectory);
 470: 
 471:             $oRootItem->addItem($oItem);
 472:             $aArrayTemp = uplRecursiveDirectoryList($sDirectory . $file . '/', $oItem, $iLevel + 1, $sParent . $file . '/', $iRenameLevel);
 473:             $aInvalidDirectories = array_merge($aInvalidDirectories, $aArrayTemp);
 474:             unset($oItem);
 475:         }
 476:     }
 477: 
 478:     return $aInvalidDirectories;
 479: }
 480: 
 481: /**
 482:  * Collects informations about all available dbfs directories stored in TreeItem
 483:  *
 484:  * @param string   $directory
 485:  *         Not used at the moment!
 486:  * @param TreeItem $oRootItem
 487:  * @param int      $level
 488:  * @param int      $client
 489:  *         client ID
 490:  *
 491:  * @throws cDbException
 492:  * @throws cException
 493:  */
 494: function uplRecursiveDBDirectoryList($directory, TreeItem $oRootItem, $level, $client) {
 495:     $dbfs = new cApiDbfsCollection();
 496:     $dbfs->select("filename = '.' AND idclient=" . cSecurity::toInteger($client), 'dirname, iddbfs, idclient, filename, mimetype, size, content, created, author, modified, modifiedby', 'dirname ASC');
 497:     $count = 0;
 498:     $lastlevel = 0;
 499:     $item['.'] = $oRootItem;
 500: 
 501:     // TODO what was this array supposed to be?
 502:     $prevobj = array();
 503:     // TODO what was this object supposed to be?
 504:     $lprevobj = new stdClass();
 505: 
 506:     while (($dbitem = $dbfs->next()) !== false) {
 507:         $dirname = $dbitem->get('dirname');
 508:         $level = cString::countSubstring($dirname, '/') + 2;
 509:         $file = basename($dbitem->get('dirname'));
 510:         $parent = dirname($dbitem->get('dirname'));
 511: 
 512:         if ($dirname != '.' && $file != '.') {
 513:             $item[$dirname] = new TreeItem($file, cApiDbfs::PROTOCOL_DBFS . '/' . $dirname, true);
 514:             $item[$dirname]->setCustom('level', $level);
 515:             $item[$dirname]->setCustom('parent', $parent);
 516:             $item[$dirname]->setCustom('lastitem', true);
 517: 
 518:             if ($item[$dirname]->getCustom('level') == $level) {
 519:                 if (isset($prevobj[$level]) && is_object($prevobj[$level])) {
 520:                     $prevobj[$level]->setCustom('lastitem', false);
 521:                 }
 522:             }
 523: 
 524:             if ($lastlevel > $level) {
 525:                 unset($prevobj[$lastlevel]);
 526:                 $lprevobj->setCustom('lastitem', true);
 527:             }
 528: 
 529:             $prevobj[$level] = $item[$dirname];
 530:             $lprevobj = $item[$dirname];
 531: 
 532:             $lastlevel = $level;
 533: 
 534:             if (is_object($item[$parent])) {
 535:                 $item[$parent]->addItem($item[$dirname]);
 536:             }
 537: 
 538:             $count++;
 539:         }
 540:     }
 541: }
 542: 
 543: /**
 544:  * Returns thumbnail for a specific upload file
 545:  *
 546:  * @param string $sFile
 547:  *         Filename to retrieve the thumbnail for
 548:  * @param int    $iMaxSize
 549:  *         Thumb dimension (size of with and heigth)
 550:  *
 551:  * @return string
 552:  * 
 553:  * @throws cDbException
 554:  * @throws cException
 555:  * @throws cInvalidArgumentException
 556:  */
 557: function uplGetThumbnail($sFile, $iMaxSize) {
 558: 
 559:     $client = cRegistry::getClientId();
 560:     $cfgClient = cRegistry::getClientConfig($client);
 561: 
 562:     if ($iMaxSize == -1) {
 563:         return uplGetFileIcon($sFile);
 564:     }
 565: 
 566:     $sFileType = cString::toLowerCase(cFileHandler::getExtension($sFile));
 567: 
 568:     switch ($sFileType) {
 569:         case "png":
 570:         case "gif":
 571:         case "tiff":
 572:         case "tif":
 573:         case "bmp":
 574:         case "jpeg":
 575:         case "jpg":
 576:         case "iff":
 577:         case "xbm":
 578:         case "wbmp":
 579:             $img = cApiImgScale($cfgClient['upl']['path'] . $sFile, $iMaxSize, $iMaxSize, false, false, 50);
 580:             if ($img !== false) {
 581:                 return $img;
 582:             }
 583:             $img = cApiImgScale(cRegistry::getBackendPath() . 'images/unknown.jpg', $iMaxSize, $iMaxSize, false, false, 50);
 584:             if ($img !== false) {
 585:                 return $img;
 586:             } else {
 587:                 return uplGetFileIcon($sFile);
 588:             }
 589:             break;
 590:         default:
 591:             return uplGetFileIcon($sFile);
 592:             break;
 593:     }
 594: }
 595: 
 596: /**
 597:  * Returns the icon for a file type
 598:  *
 599:  * @param string $sFile
 600:  *         Filename to retrieve the extension for
 601:  * @return string
 602:  *         Icon for the file type
 603:  */
 604: function uplGetFileIcon($sFile) {
 605: 
 606:     $cfg = cRegistry::getConfig();
 607: 
 608:     $sPathFiletypes = cRegistry::getBackendUrl() . $cfg['path']['images'] . 'filetypes/';
 609:     $sFileType = cString::toLowerCase(cFileHandler::getExtension($sFile));
 610: 
 611:     switch ($sFileType) {
 612:         case "sxi":
 613:         case "sti":
 614:         case "pps":
 615:         case "pot":
 616:         case "kpr":
 617:         case "pptx":
 618:         case "potx":
 619:         case "pptm":
 620:         case "potm":
 621:         case "ppt":
 622:             $icon = "ppt.gif";
 623:             break;
 624:         case "doc":
 625:         case "dot":
 626:         case "sxw":
 627:         case "stw":
 628:         case "sdw":
 629:         case "docx":
 630:         case "dotx":
 631:         case "docm":
 632:         case "dotm":
 633:         case "kwd":
 634:             $icon = "word.gif";
 635:             break;
 636:         case "xls":
 637:         case "sxc":
 638:         case "stc":
 639:         case "xlw":
 640:         case "xlt":
 641:         case "csv":
 642:         case "ksp":
 643:         case "xlsx":
 644:         case "xltx":
 645:         case "xlsm":
 646:         case "xlsb":
 647:         case "xltm":
 648:         case "sdc":
 649:             $icon = "excel.gif";
 650:             break;
 651:         case "txt":
 652:         case "rtf":
 653:             $icon = "txt.gif";
 654:             break;
 655:         case "gif":
 656:             $icon = "gif.gif";
 657:             break;
 658:         case "png":
 659:             $icon = "png.gif";
 660:             break;
 661:         case "jpeg":
 662:         case "jpg":
 663:             $icon = "jpg.gif";
 664:             break;
 665:         case "html":
 666:         case "htm":
 667:             $icon = "html.gif";
 668:             break;
 669:         case "lha":
 670:         case "rar":
 671:         case "arj":
 672:         case "bz2":
 673:         case "bz":
 674:         case "gz":
 675:         case "tar":
 676:         case "tbz2":
 677:         case "tbz":
 678:         case "tgz":
 679:         case "zip":
 680:             $icon = "zip.gif";
 681:             break;
 682:         case "pdf":
 683:             $icon = "pdf.gif";
 684:             break;
 685:         case "mov":
 686:         case "avi":
 687:         case "mpg":
 688:         case "mpeg":
 689:         case "wmv":
 690:             $icon = "movie.gif";
 691:             break;
 692:         case "swf":
 693:             $icon = "swf.gif";
 694:             break;
 695:         case "js":
 696:             $icon = "js.gif";
 697:             break;
 698:         case "vcf":
 699:             $icon = "vcf.gif";
 700:             break;
 701:         case "odf":
 702:             $icon = "odf.gif";
 703:             break;
 704:         case "php":
 705:             $icon = "php.gif";
 706:             break;
 707:         case "mp3":
 708:         case "wma":
 709:         case "ogg":
 710:         case "mp4":
 711:             $icon = "sound.gif";
 712:             break;
 713:         case "psd":
 714:         case "ai":
 715:         case "eps":
 716:         case "cdr":
 717:         case "qxp":
 718:         case "ps":
 719:             $icon = "design.gif";
 720:             break;
 721:         case "css":
 722:             $icon = "css.gif";
 723:             break;
 724:         default:
 725:             if (cFileHandler::exists($sPathFiletypes . $sFileType . '.gif')) {
 726:                 $icon = $sFileType . '.gif';
 727:             } else {
 728:                 $icon = "unknown.gif";
 729:             }
 730:             break;
 731:     }
 732: 
 733:     return $sPathFiletypes . $icon;
 734: }
 735: 
 736: /**
 737:  * Returns the description for a file type
 738:  *
 739:  * @param string $sExtension
 740:  *         Extension to use
 741:  *
 742:  * @return string
 743:  *         Text for the file type
 744:  * 
 745:  * @throws cException
 746:  */
 747: function uplGetFileTypeDescription($sExtension) {
 748: 
 749:     switch ($sExtension) {
 750:         // Presentation files
 751:         case "sxi":
 752:             return (i18n("OpenOffice.org Presentation"));
 753:         case "sti":
 754:             return (i18n("OpenOffice.org Presentation Template"));
 755:         case "pps":
 756:             return (i18n("Microsoft PowerPoint Screen Presentation"));
 757:         case "pot":
 758:             return (i18n("Microsoft PowerPoint Presentation Template"));
 759:         case "kpr":
 760:             return (i18n("KDE KPresenter Document"));
 761:         case "ppt":
 762:             return (i18n("Microsoft PowerPoint Presentation Template"));
 763: 
 764:         // Document files
 765:         case "doc":
 766:             return (i18n("Microsoft Word Document or regular text file"));
 767:         case "dot":
 768:             return (i18n("Microsoft Word Template"));
 769:         case "sxw":
 770:             return (i18n("OpenOffice.org Text Document"));
 771:         case "stw":
 772:             return (i18n("OpenOffice.org Text Document Template"));
 773:         case "sdw":
 774:             return (i18n("StarOffice 5.0 Text Document"));
 775:         case "kwd":
 776:             return (i18n("KDE KWord Document"));
 777: 
 778:         // Spreadsheet files
 779:         case "xls":
 780:             return (i18n("Microsoft Excel Worksheet"));
 781:         case "sxc":
 782:             return (i18n("OpenOffice.org Table"));
 783:         case "stc":
 784:             return (i18n("OpenOffice.org Table Template"));
 785:         case "xlw":
 786:             return (i18n("Microsoft Excel File"));
 787:         case "xlt":
 788:             return (i18n("Microsoft Excel Template"));
 789:         case "csv":
 790:             return (i18n("Comma Seperated Value File"));
 791:         case "ksp":
 792:             return (i18n("KDE KSpread Document"));
 793:         case "sdc":
 794:             return (i18n("StarOffice 5.0 Table"));
 795: 
 796:         // Text types
 797:         case "txt":
 798:             return (i18n("Plain Text"));
 799:         case "rtf":
 800:             return (i18n("Rich Text Format"));
 801: 
 802:         // Images
 803:         case "gif":
 804:             return (i18n("GIF Image"));
 805:         case "png":
 806:             return (i18n("PNG Image"));
 807:         case "jpeg":
 808:             return (i18n("JPEG Image"));
 809:         case "jpg":
 810:             return (i18n("JPEG Image"));
 811:         case "tif":
 812:             return (i18n("TIFF Image"));
 813:         case "psd":
 814:             return (i18n("Adobe Photoshop Image"));
 815: 
 816:         // HTML
 817:         case "html":
 818:             return (i18n("Hypertext Markup Language Document"));
 819:         case "htm":
 820:             return (i18n("Hypertext Markup Language Document"));
 821:         case "css":
 822:             return (i18n("Cascading Style Sheets"));
 823: 
 824:         // Archives
 825:         case "lha":
 826:             return (i18n("LHA Archive"));
 827:         case "rar":
 828:             return (i18n("RAR Archive"));
 829:         case "arj":
 830:             return (i18n("ARJ Archive"));
 831:         case "bz2":
 832:             return (i18n("bz2-compressed File"));
 833:         case "bz":
 834:             return (i18n("bzip-compressed File"));
 835:         case "zip":
 836:             return (i18n("ZIP Archive"));
 837:         case "tar":
 838:             return (i18n("TAR Archive"));
 839:         case "gz":
 840:             return (i18n("GZ Compressed File"));
 841: 
 842:         // Source files
 843:         case "c":
 844:             return (i18n("C Program Code"));
 845:         case "c++":
 846:         case "cc":
 847:         case "cpp":
 848:             return (i18n("C++ Program Code"));
 849:         case "hpp":
 850:         case "h":
 851:             return (i18n("C or C++ Program Header"));
 852:         case "php":
 853:         case "php3":
 854:         case "php4":
 855:             return (i18n("PHP Program Code"));
 856:         case "phps":
 857:             return (i18n("PHP Source File"));
 858: 
 859:         case "pdf":
 860:             return (i18n("Adobe Acrobat Portable Document"));
 861: 
 862:         // Movies
 863:         case "mov":
 864:             return (i18n("QuickTime Movie"));
 865:         case "avi":
 866:             return (i18n("avi Movie"));
 867:         case "mpg":
 868:         case "mpeg":
 869:             return (i18n("MPEG Movie"));
 870:         case "wmv":
 871:             return (i18n("Windows Media Video"));
 872:         case "mp4":
 873:             return (i18n("MPEG-4 Movie"));
 874: 
 875:         default:
 876:             return (i18n($sExtension . "-File"));
 877:     }
 878: }
 879: 
 880: /**
 881:  * Removes unwanted characters from passed filename.
 882:  *
 883:  * @param string $filename
 884:  *
 885:  * @return string
 886:  * 
 887:  * @throws cDbException
 888:  * @throws cException
 889:  */
 890: function uplCreateFriendlyName($filename) {
 891:     static $encoding;
 892: 
 893:     if (!isset($encoding)) {
 894:         $encoding = cRegistry::getEncoding();
 895:     }
 896: 
 897:     $additionalChars = cRegistry::getConfigValue('upl', 'allow_additional_chars');
 898:     if (!is_array($additionalChars)) {
 899:         $filename = str_replace(" ", "_", $filename);
 900:     } elseif (in_array(' ', $additionalChars) === FALSE) {
 901:         $filename = str_replace(" ", "_", $filename);
 902:     }
 903: 
 904:     $chars = '';
 905:     if (is_array($additionalChars)) {
 906:         $chars = implode("", $additionalChars);
 907:         $chars = str_replace(array(
 908:             '-',
 909:             '[',
 910:             ']'
 911:         ), '', $chars);
 912:     }
 913: 
 914:     $filename = cString::replaceDiacritics($filename, cString::toUpperCase($encoding));
 915:     $filename = preg_replace("/[^A-Za-z0-9._\-" . $chars . "]/i", '', $filename);
 916: 
 917:     return $filename;
 918: }
 919: 
 920: /**
 921:  *
 922:  * @param string $searchfor
 923:  *
 924:  * @return array
 925:  * 
 926:  * @throws cDbException
 927:  * @throws cException
 928:  * @throws cInvalidArgumentException
 929:  */
 930: function uplSearch($searchfor) {
 931:     $client = cRegistry::getClientId();
 932:     $client = cSecurity::toInteger($client);
 933:     $lang = cRegistry::getLanguageId();
 934:     $lang = cSecurity::toInteger($lang);
 935: 
 936:     $uploadsColl = new cApiUploadCollection();
 937:     $uplMetaColl = new cApiUploadMetaCollection();
 938: 
 939:     $searchfordb = $uplMetaColl->escape($searchfor);
 940: 
 941:     $items = array();
 942: 
 943:     // Search for description, ranking *5
 944:     $uplMetaColl->link('cApiUploadCollection');
 945:     $uplMetaColl->setWhereGroup('description', 'capiuploadcollection.idclient', $client);
 946:     $uplMetaColl->setWhereGroup('description', 'capiuploadmetacollection.idlang', $lang);
 947:     $uplMetaColl->setWhereGroup('description', 'capiuploadmetacollection.description', '%' . $searchfordb . '%', 'LIKE');
 948:     $uplMetaColl->query();
 949:     while (($item = $uplMetaColl->next()) !== false) {
 950:         $items[$item->get('idupl')] += (cString::countSubstring(cString::toLowerCase($item->get('description')), cString::toLowerCase($searchfor)) * 5);
 951:     }
 952: 
 953:     // Search for medianame, ranking *4
 954:     $uplMetaColl->resetQuery();
 955:     $uplMetaColl->link('cApiUploadCollection');
 956:     $uplMetaColl->setWhereGroup('medianame', 'capiuploadcollection.idclient', $client);
 957:     $uplMetaColl->setWhereGroup('medianame', 'capiuploadmetacollection.idlang', $lang);
 958:     $uplMetaColl->setWhereGroup('medianame', 'capiuploadmetacollection.medianame', '%' . $searchfordb . '%', 'LIKE');
 959:     $uplMetaColl->query();
 960:     while (($item = $uplMetaColl->next()) !== false) {
 961:         $items[$item->get('idupl')] += (cString::countSubstring(cString::toLowerCase($item->get('medianame')), cString::toLowerCase($searchfor)) * 4);
 962:     }
 963: 
 964:     // Search for file name, ranking +4
 965:     $uploadsColl->select("idclient='" . $client . "' AND filename LIKE '%" . $searchfordb . "%'");
 966:     while (($item = $uploadsColl->next()) !== false) {
 967:         $items[$item->get('idupl')] += 4;
 968:     }
 969: 
 970:     // Search for keywords, ranking *3
 971:     $uplMetaColl->resetQuery();
 972:     $uplMetaColl->link('cApiUploadCollection');
 973:     $uplMetaColl->setWhereGroup('keywords', 'capiuploadcollection.idclient', $client);
 974:     $uplMetaColl->setWhereGroup('keywords', 'capiuploadmetacollection.idlang', $lang);
 975:     $uplMetaColl->setWhereGroup('keywords', 'capiuploadmetacollection.keywords', '%' . $searchfordb . '%', 'LIKE');
 976:     $uplMetaColl->query();
 977:     while (($item = $uplMetaColl->next()) !== false) {
 978:         $items[$item->get('idupl')] += (cString::countSubstring(cString::toLowerCase($item->get('keywords')), cString::toLowerCase($searchfor)) * 3);
 979:     }
 980: 
 981:     // Search for copyright, ranking *2
 982:     $uplMetaColl->resetQuery();
 983:     $uplMetaColl->link('cApiUploadCollection');
 984:     $uplMetaColl->setWhereGroup('copyright', 'capiuploadcollection.idclient', $client);
 985:     $uplMetaColl->setWhereGroup('copyright', 'capiuploadmetacollection.idlang', $lang);
 986:     $uplMetaColl->setWhereGroup('copyright', 'capiuploadmetacollection.copyright', '%' . $searchfordb . '%', 'LIKE');
 987:     $uplMetaColl->query();
 988:     while (($item = $uplMetaColl->next()) !== false) {
 989:         $items[$item->get('idupl')] += (cString::countSubstring(cString::toLowerCase($item->get('copyright')), cString::toLowerCase($searchfor)) * 2);
 990:     }
 991: 
 992:     // Search for internal_notice, ranking *1
 993:     $uplMetaColl->resetQuery();
 994:     $uplMetaColl->link('cApiUploadCollection');
 995:     $uplMetaColl->setWhereGroup('internal_notice', 'capiuploadcollection.idclient', $client);
 996:     $uplMetaColl->setWhereGroup('internal_notice', 'capiuploadmetacollection.idlang', $lang);
 997:     $uplMetaColl->setWhereGroup('internal_notice', 'capiuploadmetacollection.internal_notice', '%' . $searchfordb . '%', 'LIKE');
 998:     $uplMetaColl->query();
 999:     while (($item = $uplMetaColl->next()) !== false) {
1000:         $items[$item->get('idupl')] += (cString::countSubstring(cString::toLowerCase($item->get('internal_notice')), cString::toLowerCase($searchfor)));
1001:     }
1002: 
1003:     return $items;
1004: }
1005: 
1006: /**
1007:  * Returns file extension
1008:  *
1009:  * @deprecated [2015-05-21]
1010:  *         use cFileHandler::getExtension
1011:  *
1012:  * @param string $sFile
1013:  * @param string $sDirname
1014:  *
1015:  * @return string
1016:  * 
1017:  * @throws cInvalidArgumentException
1018:  */
1019: function uplGetFileExtension($sFile, $sDirname = '') {
1020:     cDeprecated('This method is deprecated and is not needed any longer');
1021:     return cFileHandler::getExtension($sDirname . $sFile);
1022: }
1023: 
1024: /**
1025:  * Returns list of directory names to exclude e.g. from directory listings.
1026:  *
1027:  * @return array
1028:  * 
1029:  * @throws cDbException
1030:  * @throws cException
1031:  * @throws cInvalidArgumentException
1032:  */
1033: function uplGetDirectoriesToExclude() {
1034:     static $mDirsToExclude = NULL;
1035:     if (isset($mDirsToExclude)) {
1036:         return $mDirsToExclude;
1037:     }
1038: 
1039:     $mDirsToExclude = trim(getSystemProperty('system', 'upldirlist-dirstoexclude'));
1040:     if ($mDirsToExclude === '') {
1041:         $mDirsToExclude = '.,..,.svn,.cvs';
1042:         setSystemProperty('system', 'upldirlist-dirstoexclude', $mDirsToExclude);
1043:     }
1044:     $mDirsToExclude = explode(',', $mDirsToExclude);
1045:     foreach ($mDirsToExclude as $pos => $item) {
1046:         $mDirsToExclude[$pos] = trim($item);
1047:     }
1048:     return $mDirsToExclude;
1049: }
1050: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0