From 596a1efafa51833226710a59c7922ec82568c90b Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 26 Jan 2012 20:02:38 +0000 Subject: [PATCH] delete internal files after 24h --- lam/lib/ldap.inc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lam/lib/ldap.inc b/lam/lib/ldap.inc index 7aade12b..997bd6d9 100644 --- a/lam/lib/ldap.inc +++ b/lam/lib/ldap.inc @@ -167,6 +167,21 @@ class Ldap{ $file = @readdir($dir); } @closedir($dir); + // clean internal files that are older than 24 hours + $tmpDir = dirname(__FILE__) . '/../tmp/internal/'; + $time = time(); + $dir = @opendir($tmpDir); + $file = @readdir($dir); + while ($file) { + if ((substr($file, -4) == '.tmp')) { + $path = $tmpDir . $file; + if ($time - filemtime($path) > (3600 * 24)) { + @unlink($path); + } + } + $file = @readdir($dir); + } + @closedir($dir); } /**