From 2a5b7c103502a8440056acb63a546c72a5fb8d4d Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Wed, 18 Jun 2008 21:01:20 +0200 Subject: Tests if the md5sum of the temp file is the same as the stored stats file. To be used in conjunction with the filemtime, to get sure we really have up to date statistics. --- Badges_v2.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Badges_v2.php b/Badges_v2.php index f3cd6a4..ec11360 100644 --- a/Badges_v2.php +++ b/Badges_v2.php @@ -41,7 +41,9 @@ if ( ! is_file($Stats) ||(filemtime($Stats) + CACHE < $_SERVER['REQUEST_TIME'])) { system("wget -q --no-cache http://ws.audioscrobbler.com/1.0/user/".rawurlencode($username)."/profile.xml -O $Stats.tmp"); - if (!filesize("$Stats.tmp")) + if ( !filesize("$Stats.tmp") + ||(!strcmp(md5_file($Stats), md5_file("$Stats.tmp"))) + ) system("rm $Stats.tmp"); else system("mv $Stats.tmp $Stats"); -- cgit v1.2.3