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