dont track range requests

This commit is contained in:
Kieran 2017-07-05 06:08:30 +08:00
parent 766de1570a
commit 4432e840d1
3 changed files with 18 additions and 12 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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 = [];