From 4432e840d12f321d4fa38f78e53d339ea7c10c12 Mon Sep 17 00:00:00 2001 From: Kieran Date: Wed, 5 Jul 2017 06:08:30 +0800 Subject: [PATCH] dont track range requests --- download2.php | 23 +++++++++++++---------- index.php | 5 ++++- public/main.js | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/download2.php b/download2.php index 7f33e99..dbd99f9 100644 --- a/download2.php +++ b/download2.php @@ -2,18 +2,21 @@ function XFastDownload($location, $filename, $mimeType = 'application/octet-stream') { - $url = "https://www.google-analytics.com/collect"; - $payload = "v=1&tid=UA-73200448-1&cid=" . session_id() . "&t=pageview&dh=" . $_SERVER['HTTP_HOST'] . "&dp=" . urlencode($_SERVER['REQUEST_URI']) . "&uip=" . $_SERVER['REMOTE_ADDR'] . "&ua=" . urlencode($_SERVER["HTTP_USER_AGENT"]) . "&dr=" . urlencode($_SERVER["HTTP_REFERER"]); + if(!isset($_SERVER["HTTP_RANGE"])) + { + $url = "https://www.google-analytics.com/collect"; + $payload = "v=1&tid=UA-73200448-1&cid=" . session_id() . "&t=pageview&dh=" . $_SERVER['HTTP_HOST'] . "&dp=" . urlencode($_SERVER['REQUEST_URI']) . "&uip=" . $_SERVER['REMOTE_ADDR'] . "&ua=" . urlencode($_SERVER["HTTP_USER_AGENT"]) . "&dr=" . urlencode(isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : ""); - $ch = curl_init(); + $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); - - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_exec($ch); - curl_close ($ch); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_exec($ch); + curl_close ($ch); + } $expire = 604800; diff --git a/index.php b/index.php index 304d6d5..fd338af 100644 --- a/index.php +++ b/index.php @@ -13,7 +13,10 @@ include_once('download2.php'); XFastDownload(_UPLOADDIR . $f->hash160, $f->filename, $f->mime); - $db->AddView($f->hash160); + if(!isset($_SERVER["HTTP_RANGE"])) + { + $db->AddView($f->hash160); + } } exit; diff --git a/public/main.js b/public/main.js index 98fc6cd..e28360b 100644 --- a/public/main.js +++ b/public/main.js @@ -57,7 +57,7 @@ function addPasteFunctions() function loadHistory(){ var hist = localStorage.getItem("history"); - if(hist.length > 0) { + if(hist !== null && hist.length > 0) { hist = JSON.parse(hist); } else { hist = [];