From 50c0eed4cbfe1122337f7382e849ee3f4faeac85 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Mon, 25 Oct 2010 14:59:08 +0200 Subject: [Cache] better lastupdate management, and cache modification time based on it. --- BigLine.php | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/BigLine.php b/BigLine.php index b29b01a..82b9170 100644 --- a/BigLine.php +++ b/BigLine.php @@ -70,7 +70,7 @@ if (is_file($Cache) AND (filemtime($Cache) >= $data['lastupdate'])){ if (is_file($Cache)) { - SendCacheHeaders(filemtime($Cache), CACHE); + SendCacheHeaders($data["lastupdate"], CACHE); } /*----------------------------------------------------------- @@ -261,33 +261,51 @@ function make_db_cache($username){ $feed=new XMLReader(); if($feed->xml($profile_xml)){ + + $modified = FALSE; + while ($feed->read()) { switch ($feed->name) { case "playcount": $feed->read(); - $data['playcount']=intval($feed->value); + $value = intval($feed->value); + if ($data['playcount'] != $value) + { + $data['playcount']=$value; + $modified=TRUE; + } $feed->read(); break; case "registered": case "statsreset": - $data['statsstart']=$feed->getAttribute("unixtime"); + $value = feed->getAttribute("unixtime"); + if ($data['statsstart'] != $value) + { + $data['statsstart']=$value; + $modified = TRUE; + } $feed->read(); $feed->read(); break; case "profile": - $data['username']=$feed->getAttribute("username"); + $value=feed->getAttribute("username"); + if ($data['username'] != $value) + { + $data['username']=$value; + $modified = TRUE; + } break; } } - + if ($data['playcount'] != 0) { $QUERY=(sprintf("REPLACE INTO users (lastupdate,playcount,statsstart,username) VALUES ('%s',%s,'%s','%s');", - time(), $data['playcount'], gpc_addslashes($data['statsstart']), gpc_addslashes(strtolower($username)))); + ($modified ? time() : $data['lastupdate']), $data['playcount'], gpc_addslashes($data['statsstart']), gpc_addslashes(strtolower($username)))); mysql_query($QUERY); } } -- cgit v1.2.3