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:
@@ -1001,4 +1001,53 @@ class RBAC
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -40,6 +40,8 @@ try {
|
||||
$pwd = trim($frm['USR_PASSWORD']);
|
||||
}
|
||||
$uid = $RBAC->VerifyLogin($usr , $pwd);
|
||||
//cleaning session files older than 72 hours
|
||||
$RBAC->cleanSessionFiles(72);
|
||||
$sPwd = 'currentPwd';
|
||||
switch ($uid) {
|
||||
//The user does not exist
|
||||
|
||||
@@ -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(fieldsetRoot);
|
||||
fsf.add(fieldsetSession);
|
||||
fsf.render(document.getElementById('main-panel'));
|
||||
|
||||
//set the current language
|
||||
|
||||
Reference in New Issue
Block a user