Files
luos/workflow/engine/methods/setup/deleteSessions.php
jennylee 6ee79318c4 CODE STYLE, workflow/engine/methods/setup/ PART 1
FILES:
appCacheViewAjax.php
appCacheViewConf.php
appearance.php
calendarDelete.php
calendarEdit.php
calendarList.php
calendarSave.php
calendarValidate.php
calendar_Ajax.php
clearCompiled.php
clearCompiledAjax.php
connectionDB.php
connectionWS.php
cron.php
cronAjax.php
customFunctions.php
debug.php
deleteSessions.php
emailSystemCron.php
emailSystemSpool.php
emailSystemTest.php
emails.php
emails_Ajax.php
emails_Save.php
environmentSettings.php
environmentSettingsAjax.php
2012-10-17 15:40:37 -04:00

57 lines
1.4 KiB
PHP
Executable File

<?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'];