Bug 6125 removing the section inside pm cache builder and added a new method inside the rbac class in order to remove the older session files

This commit is contained in:
Gustavo Adolfo Cruz Laura
2011-02-23 22:14:04 +00:00
parent 7f9d0bac81
commit 2a1af0e504
3 changed files with 51 additions and 30 deletions

View File

@@ -1001,4 +1001,53 @@ class RBAC
exit(0); exit(0);
} }
} }
private 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;
}
private function getFilesTimestamp($directory, $recursive = true) {
$allFiles = self::getAllFiles($directory, $recursive);
$fileArray = array ();
foreach ($allFiles as $val) {
$timeResult['file'] = $val;
$timeResult['timestamp'] = filemtime($val);
$fileArray[] = $timeResult;
}
return $fileArray;
}
public function cleanSessionFiles($hours = 72){
$currentTime = strtotime("now");
$timeDifference = $hours*60*60;
$limitTime = $currentTime - $timeDifference;
$sessionsPath = PATH_DATA.'session'.PATH_SEP;
$filesResult = self::getFilesTimestamp($sessionsPath);
$count = 0;
foreach ($filesResult as $file){
if ( $file['timestamp'] < $limitTime ){
unlink ($file['file']);
$count++;
}
}
}
} }

View File

@@ -40,6 +40,8 @@ try {
$pwd = trim($frm['USR_PASSWORD']); $pwd = trim($frm['USR_PASSWORD']);
} }
$uid = $RBAC->VerifyLogin($usr , $pwd); $uid = $RBAC->VerifyLogin($usr , $pwd);
//cleaning session files older than 72 hours
$RBAC->cleanSessionFiles(72);
$sPwd = 'currentPwd'; $sPwd = 'currentPwd';
switch ($uid) { switch ($uid) {
//The user does not exist //The user does not exist

View File

@@ -185,38 +185,8 @@ Ext.onReady(function() {
}] }]
} }
fieldsetSession = {
xtype : 'fieldset',
title : TRANSLATIONS.ID_CACHE_SUBTITLE_SETUP_SESSION, // 'Deleting the sessions',
collapsible : false,
autoHeight : true,
defaults : { width : 100 },
defaultType : 'textfield',
buttons : [{
text : TRANSLATIONS.ID_CACHE_BTN_SETUP_SESSION, // 'Setup sessions',
handler : function() {
Ext.Msg.show ({ msg : TRANSLATIONS.ID_PROCESSING, wait:true,waitConfig: {interval:400} });
Ext.Ajax.request({
url: 'deleteSessions',
success: function(response) {
Ext.MessageBox.hide();
Ext.Msg.alert ( '', response.responseText );
},
failure : function(response) {
Ext.Msg.hide();
Ext.Msg.alert ( 'Error', response.responseText );
},
// params: { request: 'recreate-root', lang: 'en', host: Ext.getCmp('txtHost').getValue(), user: Ext.getCmp('txtUser').getValue(), password: Ext.getCmp('txtPasswd').getValue() },
// timeout : 1000
// 30 mins
timeout : 1000*60*30 //30 mins
});
}
}]
}
fsf.add(fieldset); fsf.add(fieldset);
fsf.add(fieldsetRoot); fsf.add(fieldsetRoot);
fsf.add(fieldsetSession);
fsf.render(document.getElementById('main-panel')); fsf.render(document.getElementById('main-panel'));
//set the current language //set the current language