// data for some reason, you must call mpInitEnvirons() instead. mpInitEnvirons(); function sortLast($a, $b) { return $b['last'] - $a['last']; } function sortTTL($a, $b) { return $a['ttl'] - $b['ttl']; } function sortSize($a, $b) { return $b['size'] - $a['size']; } if ($_REQUEST['cmd'] == "Destroy") { mpSessDestroy($_REQUEST['target']); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>MolProbity - show sessions</title> </head> <body bgcolor="#FFFFFF" text="#000000" link="#000099" vlink="#000099" alink="#990000"> <center> [ <a href='phpinfo.php'>PHP info</a> | <a href='check_config.php'>Configuration check</a> | <a href='show_sessions.php'>Live sessions</a> | <a href='usage_history.php'>Usage history</a> ] </center><hr>
function mpSessGC($maxlifetime) { // This is straightforward but unacceptably slow for thousands of sessions, // because we have to calculate both time-to-live and disk usage -- // requires a LOT of disk access. #$sessions = mpEnumerateSessions(); #foreach($sessions as $sess) #{ # // Destroy old sessions and ones that are way too big # if($sess['ttl'] < 0 || $sess['size'] > 1.5*MP_SESSION_MAX_SIZE) # mpSessDestroy($sess['id']); #} // Time-limited, probabalistic cleanup of old / oversize sessions // 1. Enumerate IDs of all active sessions. $start = microtime(); // seconds, as string $session_ids = array(); //$baseDataDir = MP_BASE_DIR."/public_html/data"; $baseDataDir = substr(MP_JOB_DATA_DIR, 0, strlen(MP_JOB_DATA_DIR) - 1); $h = opendir($baseDataDir); while (($id = readdir($h)) != false) { // Assume they're directories for now so we don't have to touch the disk so much if (preg_match('/^[a-zA-Z0-9_]{16,64}$/', $id)) { $session_ids[$id] = $id; } } closedir($h); // 2. Iterate over sessions in random order until we cover them all or run out of time shuffle($session_ids); foreach ($session_ids as $id) { // Confirm now that they're really directories if (!is_dir("{$baseDataDir}/{$id}")) { continue; } $lifetime = mpSessLifetime($id); $ttl = $lifetime['ttl']; $size = mpSessSizeOnDisk($id); if ($ttl < 0 || $size > 1.5 * MP_SESSION_MAX_SIZE) { mpSessDestroy($id); } $ellapsed = microtimeSubtract(microtime(), $start); //echo "$ellapsed seconds ellapsed...\n"; if ($ellapsed > 1.0) { break; } } return true; }