|
61 | 61 | die('File is not an image');
|
62 | 62 | }
|
63 | 63 |
|
64 |
| -$file_salt = 'v1.0.1'; |
| 64 | +$file_salt = 'v1.0.2'; |
65 | 65 | $file_size = filesize($src);
|
66 | 66 | $file_time = filemtime($src);
|
67 | 67 | $file_date = gmdate('D, d M Y H:i:s T', $file_time);
|
|
72 | 72 | if (!file_exists(THUMB_CACHE . 'index.html')) {
|
73 | 73 | touch(THUMB_CACHE . 'index.html');
|
74 | 74 | }
|
75 |
| -$fp = fopen(THUMB_CACHE . 'index.html', 'r'); |
76 |
| -if (flock($fp, LOCK_EX)) { |
77 |
| - if (time() - THUMB_CACHE_AGE > filemtime(THUMB_CACHE . 'index.html')) { |
78 |
| - $files = glob(THUMB_CACHE . '*.img.txt'); |
79 |
| - if (is_array($files) && count($files) > 0) { |
80 |
| - foreach ($files as $file) { |
81 |
| - if (time() - THUMB_CACHE_AGE > filemtime($file)) { |
82 |
| - unlink($file); |
| 75 | +if (($fp = fopen(THUMB_CACHE . 'index.html', 'r')) !== false) { |
| 76 | + if (flock($fp, LOCK_EX)) { |
| 77 | + if (time() - THUMB_CACHE_AGE > filemtime(THUMB_CACHE . 'index.html')) { |
| 78 | + $files = glob(THUMB_CACHE . '*.img.txt'); |
| 79 | + if (is_array($files) && count($files) > 0) { |
| 80 | + foreach ($files as $file) { |
| 81 | + if (time() - THUMB_CACHE_AGE > filemtime($file)) { |
| 82 | + unlink($file); |
| 83 | + } |
83 | 84 | }
|
84 | 85 | }
|
| 86 | + touch(THUMB_CACHE . 'index.html'); |
85 | 87 | }
|
86 |
| - touch(THUMB_CACHE . 'index.html'); |
| 88 | + flock($fp, LOCK_UN); |
87 | 89 | }
|
88 |
| - flock($fp, LOCK_UN); |
| 90 | + fclose($fp); |
89 | 91 | }
|
90 |
| -fclose($fp); |
91 | 92 |
|
92 | 93 | if (THUMB_BROWSER_CACHE && (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH']))) {
|
93 | 94 | if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $file_date && $_SERVER['HTTP_IF_NONE_MATCH'] == $file_hash) {
|
|
0 commit comments