diff --git a/gulliver/system/class.rbac.php b/gulliver/system/class.rbac.php index d8d333f27..16c1fd3bb 100644 --- a/gulliver/system/class.rbac.php +++ b/gulliver/system/class.rbac.php @@ -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++; + } + } +} + + } \ No newline at end of file diff --git a/workflow/engine/methods/login/authentication.php b/workflow/engine/methods/login/authentication.php index b15e2c048..012fe1bf9 100644 --- a/workflow/engine/methods/login/authentication.php +++ b/workflow/engine/methods/login/authentication.php @@ -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 diff --git a/workflow/engine/templates/setup/appCacheViewConf.js b/workflow/engine/templates/setup/appCacheViewConf.js index 3361c644a..3aca1f082 100755 --- a/workflow/engine/templates/setup/appCacheViewConf.js +++ b/workflow/engine/templates/setup/appCacheViewConf.js @@ -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