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:  * This file contains the the system purge class.
  4:  *
  5:  * @package Core
  6:  * @subpackage Backend
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Munkh-Ulzii Balidar
 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: /**
 19:  * CONTENIDO cSystemPurge class to reset some datas and files
 20:  *
 21:  * @package Core
 22:  * @subpackage Backend
 23:  */
 24: class cSystemPurge {
 25: 
 26:     /**
 27:      * These directories should not be deleted.
 28:      *
 29:      * @var array
 30:      */
 31:     private $_dirsExcluded = array(
 32:         'code',
 33:         'templates_c'
 34:     );
 35: 
 36:     /**
 37:      * These directories and the included files should not be cleared.
 38:      *
 39:      * @var array
 40:      */
 41:     private $_dirsExcludedWithFiles = array(
 42:         '.',
 43:         '..',
 44:         '.svn',
 45:         '.cvs',
 46:         '.htaccess',
 47:         '.git',
 48:         '.gitignore',
 49:         '.keep',
 50:     );
 51: 
 52:     /**
 53:      *
 54:      * @var array
 55:      */
 56:     private $_logFileTypes = array(
 57:         'txt'
 58:     );
 59: 
 60:     /**
 61:      *
 62:      * @var array
 63:      */
 64:     private $_cronjobFileTypes = array(
 65:         'job'
 66:     );
 67: 
 68:     /**
 69:      * Constructor of class.
 70:      */
 71:     public function __construct() {
 72:         // check and set the system directories to exclude from purge
 73:         $dirsToExcludeWithFiles = getSystemProperty('system', 'purge-dirstoexclude-withfiles');
 74:         $aDirsToExcludeWithFiles = array_map('trim', explode(',', $dirsToExcludeWithFiles));
 75:         if (count($aDirsToExcludeWithFiles) < 1 || empty($aDirsToExcludeWithFiles[0])) {
 76:             $aDirsToExcludeWithFiles = $this->_dirsExcludedWithFiles;
 77:             setSystemProperty('system', 'purge-dirstoexclude-withfiles', implode(',', $aDirsToExcludeWithFiles));
 78:         }
 79: 
 80:         $this->_dirsExcludedWithFiles = $aDirsToExcludeWithFiles;
 81:     }
 82: 
 83:     /**
 84:      * Deletes the PHP files in cms/cache/code.
 85:      *
 86:      * @param int $clientId
 87:      * @return bool
 88:      */
 89:     public function resetClientConCode($clientId) {
 90:         global $perm, $currentuser;
 91:         $cfgClient = cRegistry::getClientConfig();
 92: 
 93:         if (cFileHandler::exists($cfgClient[$clientId]['cache']['path'] . 'code/') === false) {
 94:             return false;
 95:         }
 96: 
 97:         if ($perm->isClientAdmin($clientId, $currentuser) === false && $perm->isSysadmin($currentuser) === false) {
 98:             return false;
 99:         }
100: 
101:         /* @var $file SplFileInfo */
102:         foreach (new DirectoryIterator($cfgClient[$clientId]['code']['path']) as $file) {
103:             if ($file->isFile() === false) {
104:                 continue;
105:             }
106: 
107:             $extension = substr($file, strrpos($file->getBasename(), '.') + 1);
108:             if ($extension != 'php') {
109:                 continue;
110:             }
111: 
112:             if (cFileHandler::remove($cfgClient[$clientId]['code']['path'] . '/' . $file->getFilename()) === false) {
113:                 return false;
114:             }
115:         }
116: 
117:         return true;
118:     }
119: 
120:     /**
121:      * Reset the table con_cat_art for a client.
122:      *
123:      * @param int $clientId
124:      * @return bool
125:      */
126:     public function resetClientConCatArt($clientId) {
127:         global $perm, $currentuser;
128:         $db = cRegistry::getDb();
129:         $cfg = cRegistry::getConfig();
130: 
131:         if ($perm->isClientAdmin($clientId, $currentuser) || $perm->isSysadmin($currentuser)) {
132:             $db->query('
133:                 UPDATE
134:                     ' . $cfg['tab']['cat_art'] . ' cca,
135:                     ' . $cfg['tab']['cat'] . ' cc,
136:                     ' . $cfg['tab']['art'] . ' ca
137:                 SET
138:                     cca.createcode=1
139:                 WHERE
140:                     cc.idcat = cca.idcat
141:                     AND ca.idart = cca.idart
142:                     AND cc.idclient = ' . (int) $clientId . '
143:                     AND ca.idclient = ' . (int) $clientId);
144: 
145:             return ($db->getErrorMessage() == '') ? true : false;
146:         } else {
147:             return false;
148:         }
149:     }
150: 
151:     /**
152:      * Reset the table con_inuse.
153:      *
154:      * @return bool
155:      */
156:     public function resetConInuse() {
157:         global $perm, $currentuser;
158:         $db = cRegistry::getDb();
159:         $cfg = cRegistry::getConfig();
160: 
161:         if ($perm->isSysadmin($currentuser)) {
162:             $sql = 'DELETE FROM ' . $cfg['tab']['inuse'];
163:             $db->query($sql);
164: 
165:             return ($db->getErrorMessage() == '') ? true : false;
166:         } else {
167:             return false;
168:         }
169:     }
170: 
171:     /**
172:      * Clear the cache directory for a client.
173:      *
174:      * @param int $clientId
175:      * @return bool
176:      */
177:     public function clearClientCache($clientId) {
178:         global $perm, $currentuser;
179:         $cfgClient = cRegistry::getClientConfig();
180: 
181:         if ($perm->isClientAdmin($clientId, $currentuser) || $perm->isSysadmin($currentuser)) {
182:             $cacheDir = $cfgClient[$clientId]['cache']['path'];
183:             if (is_dir($cacheDir)) {
184:                 return ($this->clearDir($cacheDir, $cacheDir) ? true : false);
185:             }
186:             return false;
187:         } else {
188:             return false;
189:         }
190:     }
191: 
192:     /**
193:      * Clear the cache directory for a client.
194:      *
195:      * @param int $clientId
196:      * @param bool $keep
197:      * @param int $fileNumber
198:      * @return bool
199:      */
200:     public function clearClientHistory($clientId, $keep, $fileNumber) {
201:         global $perm, $currentuser;
202:         $cfgClient = cRegistry::getClientConfig();
203: 
204:         if ($perm->isClientAdmin($clientId, $currentuser) || $perm->isSysadmin($currentuser)) {
205:             $versionDir = $cfgClient[$clientId]['version']['path'];
206:             if (is_dir($versionDir)) {
207:                 $tmpFile = array();
208:                 $this->clearDir($versionDir, $versionDir, $keep, $tmpFile);
209:                 if (count($tmpFile) > 0) {
210:                     foreach ($tmpFile as $sKey => $aFiles) {
211:                         // sort the history files with filename
212:                         array_multisort($tmpFile[$sKey]);
213: 
214:                         $count = count($tmpFile[$sKey]);
215:                         // find the total number to delete
216:                         $countDelete = ($count <= $fileNumber) ? 0 : ($count - $fileNumber);
217:                         // delete the files
218:                         for ($i = 0; $i < $countDelete; $i++) {
219:                             if (cFileHandler::exists($tmpFile[$sKey][$i]) && is_writable($tmpFile[$sKey][$i])) {
220:                                 unlink($tmpFile[$sKey][$i]);
221:                             }
222:                         }
223:                     }
224:                 }
225: 
226:                 return true;
227:             }
228:             return false;
229:         } else {
230:             return false;
231:         }
232:     }
233: 
234:     /**
235:      * Clear the clients content versioning.
236:      *
237:      * @param int $idclient
238:      * @return bool
239:      */
240:     public function clearClientContentVersioning($idclient) {
241:         global $perm, $currentuser;
242: 
243:         if ($perm->isClientAdmin($idclient, $currentuser) || $perm->isSysadmin($currentuser)) {
244: 
245:             $artLangVersionColl = new cApiArticleLanguageVersionCollection();
246:             $artLangVersionColl->deleteByWhereClause('idartlangversion != 0');
247: 
248:             $contentVersionColl = new cApiContentVersionCollection();
249:             $contentVersionColl->deleteByWhereClause('idcontentversion != 0');
250: 
251:             $metaTagVersionColl = new cApiMetaTagVersionCollection();
252:             $metaTagVersionColl->deleteByWhereClause('idmetatagversion != 0');
253: 
254:             return true;
255:         } else {
256:             return false;
257:         }
258:     }
259: 
260:     /**
261:      * Clear client log file.
262:      *
263:      * @param int $idclient
264:      * @return bool
265:      */
266:     public function clearClientLog($idclient) {
267:         global $perm, $currentuser;
268:         $cfgClient = cRegistry::getClientConfig();
269: 
270:         if ($perm->isClientAdmin($idclient, $currentuser) || $perm->isSysadmin($currentuser)) {
271:             $logDir = $cfgClient[$idclient]['log']['path'];
272:             if (is_dir($logDir)) {
273:                 return $this->emptyFile($logDir, $this->_logFileTypes);
274:             }
275:             return false;
276:         } else {
277:             return false;
278:         }
279:     }
280: 
281:     /**
282:      * Clear CONTENIDO log files.
283:      *
284:      * @return bool
285:      */
286:     public function clearConLog() {
287:         global $perm, $currentuser;
288:         $cfg = cRegistry::getConfig();
289: 
290:         $logDir = $cfg['path']['contenido_logs'];
291:         if ($perm->isSysadmin($currentuser)) {
292:             if (is_dir($logDir)) {
293:                 return $this->emptyFile($logDir, $this->_logFileTypes);
294:             }
295:             return false;
296:         } else {
297:             return false;
298:         }
299:     }
300: 
301:     /**
302:      * Clear the cronjob directory.
303:      *
304:      * @return bool
305:      */
306:     public function clearConCronjob() {
307:         global $perm, $currentuser;
308:         $cfg = cRegistry::getConfig();
309: 
310:         $cronjobDir = $cfg['path']['contenido_cronlog'];
311:         if ($perm->isSysadmin($currentuser)) {
312:             if (is_dir($cronjobDir)) {
313:                 return $this->emptyFile($cronjobDir, $this->_cronjobFileTypes);
314:             }
315:             return false;
316:         } else {
317:             return false;
318:         }
319:     }
320: 
321:     /**
322:      * Clear the cache directory for a client.
323:      *
324:      * @return bool
325:      */
326:     public function clearConCache() {
327:         global $perm, $currentuser;
328:         $cfg = cRegistry::getConfig();
329: 
330:         $cacheDir = $cfg['path']['contenido_cache'];
331:         if ($perm->isSysadmin($currentuser)) {
332:             if (is_dir($cacheDir)) {
333:                 return ($this->clearDir($cacheDir, $cacheDir) ? true : false);
334:             }
335:             return false;
336:         } else {
337:             return false;
338:         }
339:     }
340: 
341:     /**
342:      * Clears the article cache of the article which is defined by the given
343:      * parameters.
344:      *
345:      * @param int $idartlang
346:      *         the idartlang of the article
347:      */
348:     public function clearArticleCache($idartlang) {
349:         $cfgClient = cRegistry::getClientConfig();
350:         $client = cRegistry::getClientId();
351: 
352:         $artLang = new cApiArticleLanguage($idartlang);
353:         $idlang = $artLang->get('idlang');
354:         $idart = $artLang->get('idart');
355:         $art = new cApiArticle($idart);
356:         $idclient = $art->get('idclient');
357: 
358:         $catArtColl = new cApiCategoryArticleCollection();
359:         $catArtColl->select('idart=' . $idart);
360:         while (($item = $catArtColl->next()) !== false) {
361:             $filename = $cfgClient[$client]['code']['path'] . $idclient . '.' . $idlang . '.' . $item->get('idcatart') . '.php';
362:             if (cFileHandler::exists($filename)) {
363:                 cFileHandler::remove($filename);
364:             }
365:         }
366:     }
367: 
368:     /**
369:      * Delete all files and sub directories in a directory.
370:      *
371:      * @param string $dirPath
372:      * @param string $tmpDirPath
373:      *         root directory not deleted
374:      * @param bool $keep [optional]
375:      * @param array $tmpFileList [optional]
376:      *         files are temporarily saved
377:      * @return bool
378:      */
379:     public function clearDir($dirPath, $tmpDirPath, $keep = false, &$tmpFileList = array()) {
380:         if (is_dir($dirPath) && false !== ($handle = cDirHandler::read($dirPath))) {
381:             $tmp = str_replace(array(
382:                 '/',
383:                 '..'
384:             ), '', $dirPath);
385:             foreach ($handle as $file) {
386:                 if (!in_array($file, $this->_dirsExcludedWithFiles)) {
387:                     $filePath = $dirPath . '/' . $file;
388:                     $filePath = str_replace('//', '/', $filePath);
389:                     if (is_dir($filePath)) {
390:                         $this->clearDir($filePath, $tmpDirPath, $keep, $tmpFileList);
391:                     } else {
392:                         if ($keep === false) {
393:                             cFileHandler::remove($filePath);
394:                         } else {
395:                             $tmpFileList[$tmp][] = $filePath;
396:                         }
397:                     }
398:                 }
399:             }
400: 
401:             $dirs = explode('/', $dirPath);
402:             if (end($dirs) == '') {
403:                 array_pop($dirs);
404:             }
405:             $dirName = end($dirs);
406: 
407:             if (str_replace(array(
408:                 '/',
409:                 '..'
410:             ), '', $dirPath) != str_replace(array(
411:                 '/',
412:                 '..'
413:             ), '', $tmpDirPath)
414:             && $keep === false) {
415:                 // check if directoy contains reserved files folders
416:                 $bCanDelete = true;
417:                 $dirContent = cDirHandler::read($dirPath);
418:                 foreach ($dirContent as $sContent) {
419:                     if (in_array($sContent, $this->_dirsExcludedWithFiles)
420:                     || in_array($dirContent, $this->_dirsExcluded)) {
421:                         $bCanDelete = false;
422:                         break;
423:                     }
424:                 }
425:                 if (true === $bCanDelete
426:                 && in_array($dirName, $this->_dirsExcluded)) {
427:                     $bCanDelete = false;
428:                 }
429:             }
430:             // reserved files or folders, do not delete
431:             if (true === $bCanDelete) {
432:                 cDirHandler::remove($dirPath);
433:             }
434: 
435:             return true;
436:         } else {
437:             return false;
438:         }
439:     }
440: 
441:     /**
442:      * Empty a file content.
443:      *
444:      * @param string $dirPath
445:      * @param array $types
446:      * @return bool
447:      */
448:     public function emptyFile($dirPath, $types) {
449:         $count = 0;
450:         $countCleared = 0;
451: 
452:         if (is_dir($dirPath) && false !== ($handle = cDirHandler::read($dirPath))) {
453:             foreach ($handle as $file) {
454:                 $fileExt = trim(end(explode('.', $file)));
455: 
456:                 if ($file != '.' && $file != '..' && in_array($fileExt, $types)) {
457:                     $filePath = $dirPath . '/' . $file;
458: 
459:                     if (cFileHandler::exists($filePath) && cFileHandler::writeable($filePath)) {
460:                         $count++;
461: 
462:                         if (cFileHandler::truncate($filePath)) {
463:                             $countCleared++;
464:                         }
465:                     }
466:                 }
467:             }
468: 
469:             // true if all files are cleaned
470:             return ($count == $countCleared) ? true : false;
471:         }
472: 
473:         return false;
474:     }
475: 
476:     /**
477:      * Get frontend directory name for a client.
478:      *
479:      * @param int $clientId
480:      * @return string
481:      */
482:     public function getClientDir($clientId) {
483:         $cfgClient = cRegistry::getClientConfig();
484: 
485:         return $cfgClient[$clientId]['path']['frontend'];
486:     }
487: 
488:     /**
489:      * Set log file types.
490:      *
491:      * @param array $types
492:      */
493:     public function setLogFileTypes($types) {
494:         if (count($types) > 0) {
495:             foreach ($types as $type) {
496:                 $this->_logFileTypes[] = $type;
497:             }
498:         }
499:     }
500: 
501:     /**
502:      * Set cronjob file types.
503:      *
504:      * @param array $types
505:      */
506:     public function setCronjobFileTypes($types) {
507:         if (count($types) > 0) {
508:             foreach ($types as $type) {
509:                 $this->_cronjobFileTypes[] = $type;
510:             }
511:         }
512:     }
513: 
514: }
515: 
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0