From 4b43b5dfab6ab4615327f8e363cad782c67122dd Mon Sep 17 00:00:00 2001 From: IoTgod Date: Wed, 13 Mar 2019 17:55:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=20heartbeat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/cn/home/www/cdn/heartbeat/heartbeat_footer.min.js | 4 +++- server/cn/home/www/cdn/heartbeat/heartbeat_head.min.js | 2 ++ server/cn/home/www/log/heartbeat.php | 3 ++- server/cn/home/www/log/heartbeat_get.php | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/server/cn/home/www/cdn/heartbeat/heartbeat_footer.min.js b/server/cn/home/www/cdn/heartbeat/heartbeat_footer.min.js index 4f61606..5ba90b7 100644 --- a/server/cn/home/www/cdn/heartbeat/heartbeat_footer.min.js +++ b/server/cn/home/www/cdn/heartbeat/heartbeat_footer.min.js @@ -7,7 +7,9 @@ var __tmpCookie = ""; if(__isCookie && __tmpCookie != document.cookie){ - $.post("https://log.yimian.xyz/heartbeat.php",{"fp":fp, "cookie":document.cookie}); + var t = Date.parse(new Date())/1000; + cookie.set('_t', t); + $.post("https://log.yimian.xyz/heartbeat.php",{"fp":fp, "cookie":document.cookie, "tt":t}); cookie.set('fp',fp); __tmpCookie = document.cookie; } diff --git a/server/cn/home/www/cdn/heartbeat/heartbeat_head.min.js b/server/cn/home/www/cdn/heartbeat/heartbeat_head.min.js index fb3e52e..d2aebb7 100644 --- a/server/cn/home/www/cdn/heartbeat/heartbeat_head.min.js +++ b/server/cn/home/www/cdn/heartbeat/heartbeat_head.min.js @@ -12,6 +12,8 @@ var __isCookie = 0; if(t > obj.t && t < obj.t + 30) __isCookie = 1; + if(cookie.get("_t") == obj.tt) return; + var aCookie = obj.cookie.split("; "); var _obj = new Object(); for(var i = 0; i < aCookie.length; i++){ diff --git a/server/cn/home/www/log/heartbeat.php b/server/cn/home/www/log/heartbeat.php index 1f16e1c..13c12f8 100644 --- a/server/cn/home/www/log/heartbeat.php +++ b/server/cn/home/www/log/heartbeat.php @@ -5,6 +5,7 @@ header("Access-Control-Allow-Origin: *"); $fp=$_REQUEST['fp']; $ip=$_REQUEST['ip']; +$tt=$_REQUEST['tt']; $cookie=$_REQUEST['cookie']; $city=$_REQUEST['city']; $from=$_SERVER['HTTP_REFERER']; @@ -14,7 +15,7 @@ $conn=db__connect(); if(isset($_REQUEST['cookie'])){ db__delData($conn,"fp_cookie","fp",$fp); - db__pushData($conn,"fp_cookie",array("fp" => $fp, "cookie" => $cookie)); + db__pushData($conn,"fp_cookie",array("fp" => $fp, "timestamp" => $tt, "cookie" => $cookie)); }else{ diff --git a/server/cn/home/www/log/heartbeat_get.php b/server/cn/home/www/log/heartbeat_get.php index 1774317..9d66afa 100644 --- a/server/cn/home/www/log/heartbeat_get.php +++ b/server/cn/home/www/log/heartbeat_get.php @@ -11,4 +11,4 @@ $arr = array(); $cookie = $res[0]['cookie']; -echo json_encode(array("cookie" => $cookie, "t" => time())); \ No newline at end of file +echo json_encode(array("cookie" => $cookie, "t" => time(), "tt" => $res[0]['timestamp'])); \ No newline at end of file