diff --git a/include/webdav_cache_validation.inc.php b/include/webdav_cache_validation.inc.php new file mode 100644 index 0000000..f5400e8 --- /dev/null +++ b/include/webdav_cache_validation.inc.php @@ -0,0 +1,66 @@ +get_size(); + $expected_width = (int)($expected[0] ?? 0); + $expected_height = (int)($expected[1] ?? 0); + if ($expected_width > 0 && $expected_height > 0) + { + if ((int)$actual[0] !== $expected_width || (int)$actual[1] !== $expected_height) + { + $reason = 'dimension-mismatch:'.(int)$actual[0].'x'.(int)$actual[1].'!='.$expected_width.'x'.$expected_height; + return false; + } + } + } + + if (is_object($params) && isset($params->last_mod_time)) + { + $mtime = @filemtime($target_path); + if ($mtime === false || (int)$mtime < (int)$params->last_mod_time) + { + $reason = 'stale-params'; + return false; + } + } + + $reason = 'valid'; + return true; +}