Bug 6125 A new option has been added in order to clean the older than 72hrs session files, inside the cache builder options in the Session Maintenance section

This commit is contained in:
Gustavo Adolfo Cruz Laura
2011-02-22 22:12:01 +00:00
parent ad4a86c055
commit 4029c00b1a
2 changed files with 56 additions and 1 deletions

View File

@@ -28,7 +28,7 @@
$labels = G::getTranslations(Array(
'ID_PROCESSING', 'ID_CACHE_LANGUAGE', 'ID_CACHE_HOST', 'ID_CACHE_USER', 'ID_CACHE_PASSWORD',
'ID_CACHE_TITLE_INFO', 'ID_CACHE_SUBTITLE_REBUILD', 'ID_CACHE_BTN_BUILD',
'ID_CACHE_BUILDING', 'ID_CACHE_SUBTITLE_SETUP_DB', 'ID_CACHE_BTN_SETUP_PASSWRD'
'ID_CACHE_BUILDING', 'ID_CACHE_SUBTITLE_SETUP_DB', 'ID_CACHE_BTN_SETUP_PASSWRD', 'ID_CACHE_SUBTITLE_SETUP_SESSION', 'ID_CACHE_BTN_SETUP_SESSION'
));
$oHeadPublisher->assign('TRANSLATIONS', $labels);
// $TRANSLATIONS->ID_PROCESSING = G::LoadTranslation('ID_PROCESSING');

View File

@@ -0,0 +1,55 @@
<?php
function getAllFiles($directory, $recursive = true ) {
$result = array();
$handle = opendir($directory);
while ($datei = readdir($handle))
{
if (($datei != '.') && ($datei != '..'))
{
$file = $directory.$datei;
if (is_dir($file)) {
if ($recursive) {
$result = array_merge($result, getAllFiles($file.'/'));
}
} else {
$result[] = $file;
}
}
}
closedir($handle);
return $result;
}
function getFilesTimestamp($directory, $recursive = true) {
$allFiles = getAllFiles($directory, $recursive);
$fileArray = array ();
foreach ($allFiles as $val) {
$timeResult['file'] = $val;
$timeResult['timestamp'] = filemtime($val);
$fileArray[] = $timeResult;
}
return $fileArray;
}
$currentTime = strtotime("now");
$timeDifference = 72*60*60;
$limitTime = $currentTime - $timeDifference;
$sessionsPath = PATH_DATA.'session'.PATH_SEP;
$filesResult = getFilesTimestamp($sessionsPath);
$count = 0;
foreach ($filesResult as $file){
if ( $file['timestamp'] < $limitTime ){
unlink ($file['file']);
$count++;
}
}
if ($count>0) {
$response['message'] = G::loadTranslation('ID_REMOVED_SESSION_FILES');
} else {
$response['message'] = G::loadTranslation('ID_NO_OLDER_SESSION_FILES');
}
echo $response['message'];
?>