From 56089892d06c51bedf824f132e5a8226d7b399ed Mon Sep 17 00:00:00 2001 From: Kieran Date: Wed, 3 Oct 2018 17:07:17 +0800 Subject: [PATCH] update --- src/php/download.php | 15 ++++++++++++--- src/php/functions.php | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/php/download.php b/src/php/download.php index 416db98..02c0573 100644 --- a/src/php/download.php +++ b/src/php/download.php @@ -5,11 +5,20 @@ $redis = new Redis(); $redis->pconnect(_REDIS_SERVER); - ga_page_view($redis); + if(!isset($_SERVER['HTTP_RANGE'])) { + matomo_page_view($redis); + } $hash = substr($_SERVER["REQUEST_URI"], 1); $hashKey = _UIP . ':' . $hash; + $redis->publish('dl-track', json_encode(array( + "uid" => $_COOKIE["VC:UID"], + "uip" => _UIP, + "hash" => $hash, + "range" => $_SERVER['HTTP_RANGE'] + ))); + if(_IS_LB_HOST == False && count(_LB_HOSTS) > 0) { $has_cache = $redis->sIsMember("VC:DL:LB", $hash); if($has_cache == False) { @@ -24,11 +33,11 @@ if($lb_hash_cache == True){ $redis->sadd("VC:DL:LB", $hash); - header("location: https://" . _LB_HOSTNAME . "/" . $hash); + header("location: https://" . _LB_HOSTNAME . "/" . $hash, true, 301); exit(); } } else { - header("location: https://" . _LB_HOSTNAME . "/" . $hash); + header("location: https://" . _LB_HOSTNAME . "/" . $hash, true, 301); exit(); } } diff --git a/src/php/functions.php b/src/php/functions.php index 00fe1e9..b62e4bd 100644 --- a/src/php/functions.php +++ b/src/php/functions.php @@ -224,7 +224,7 @@ "rec" => 1, "apiv" => 1, "_id" => isset($_COOKIE["VC:UID"]) ? $_COOKIE["VC:UID"] : uniqid(), - "url" => "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]", + "url" => (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]", "cip" => _UIP, "ua" => isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : "", "urlref" => isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : ""