From: Jerome Jutteau Date: Mon, 31 Dec 2012 14:08:50 +0000 (+0100) Subject: Fix potential error: do not scan for .tmp files X-Git-Tag: 1.0~15 X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/commitdiff_plain/1fe28b19ecaaeedfb9b5087f6d8c742968934ddb?hp=9acb3ce88f77251d53f2af8048c467f1c453fe40 Fix potential error: do not scan for .tmp files Fix clean function --- diff --git a/lib/functions.php b/lib/functions.php index 10e9868..d4a5e6a 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -118,9 +118,11 @@ jirafeau_delete ($link) fclose ($handle); } - if ($counter == 0 && file_exists ( VAR_FILES . $md5)) + if ($counter == 0) { - unlink ( VAR_FILES . $md5); + if (file_exists (VAR_FILES . $md5)) + unlink ( VAR_FILES . $md5); + if (file_exists (VAR_FILES . $md5 . '_count')) unlink ( VAR_FILES . $md5. '_count'); } } @@ -136,7 +138,8 @@ jirafeau_delete_file ($md5) foreach ($links_dir as $link) { - if (strcmp ($link, '.') == 0 || strcmp ($link, '..') == 0) + if (strcmp ($link, '.') == 0 || strcmp ($link, '..') == 0 || + preg_match ('/\.tmp/i', "$link")) continue; /* Read link informations. */ $l = jirafeau_get_link ($link); @@ -400,7 +403,8 @@ jirafeau_admin_list ($name, $file_hash, $link_hash) echo ''; foreach ($links_dir as $link) { - if (strcmp ($link, '.') == 0 || strcmp ($link, '..') == 0) + if (strcmp ($link, '.') == 0 || strcmp ($link, '..') == 0 || + preg_match ('/\.tmp/i', "$link")) continue; /* Read link informations. */ $l = jirafeau_get_link ($link); @@ -452,13 +456,15 @@ jirafeau_admin_clean () foreach ($links_dir as $link) { - if (strcmp ($link, '.') == 0 || strcmp ($link, '..') == 0) + if (strcmp ($link, '.') == 0 || strcmp ($link, '..') == 0 || + preg_match ('/\.tmp/i', "$link")) continue; /* Read link informations. */ $l = jirafeau_get_link ($link); - if ($l['time'] > 0 && $l['time'] < time ()) + if ($l['time'] > 0 && $l['time'] < time () || // expired + !file_exists (VAR_FILES . $l['md5']) || // invalid + !file_exists (VAR_FILES . $l['md5'] . '_count')) // invalid { - echo 'HAAAA' . $l['time'] . '-->' . time (); jirafeau_delete ($link); $c++; }