summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2010-10-25 14:59:08 +0200
committerHugues Hiegel <hugues@hiegel.fr>2010-10-25 14:59:08 +0200
commit50c0eed4cbfe1122337f7382e849ee3f4faeac85 (patch)
tree082425ff463024363ca32dd5c9b8c2d13f9e7447
parenta29cb8536113fb389ee0a760c8c0ffe2f418acb7 (diff)
[Cache] better lastupdate management, and cache modification time based on it.
-rw-r--r--BigLine.php30
1 files 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);
}
}