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