Merge branch 'master' into docker
This commit is contained in:
commit
065baa8236
4
doc.md
4
doc.md
|
@ -330,7 +330,7 @@ If you see a table called `speedtest_users`, empty, you did it right.
|
|||
|
||||
### Configuring `telemetry.php`
|
||||
Open telemetry_settings.php with notepad or a similar text editor.
|
||||
Set your preferred database, ``$db_type="mysql";``, ``$db_type="sqlite";``, ``$db_type="postgresql";`` or or ``$db_type="csv";``
|
||||
Set your preferred database, ``$db_type="mysql";``, ``$db_type="sqlite";``, ``$db_type="postgresql";`` or ``$db_type="csv";``
|
||||
If you choose to use Sqlite3, you must set the path to your database file:
|
||||
```php
|
||||
$Sqlite_db_file = "../telemetry.sql";
|
||||
|
@ -363,7 +363,7 @@ __Note__: CSV currently only supports basic telemetry, the log will not be saved
|
|||
Edit your test page; where you start the worker, you need to specify the `telemetry_level`.
|
||||
There are 3 levels:
|
||||
* `none`: telemetry is disabled (default)
|
||||
* `basic`: telemetry collects IP, User Agent, Preferred language, Test results
|
||||
* `basic`: telemetry collects IP, ISP info, User Agent, Preferred language, Test results
|
||||
* `full`: same as above, but also collects a log (10-150 Kb each, not recommended)
|
||||
|
||||
Example:
|
||||
|
|
|
@ -442,7 +442,7 @@ function pingTest (done) {
|
|||
if (i < settings.count_ping) doPing(); else done() // more pings to do?
|
||||
}
|
||||
}.bind(this)
|
||||
// sent xhr
|
||||
// send xhr
|
||||
xhr[0].open('GET', settings.url_ping + url_sep(settings.url_ping) + 'r=' + Math.random(), true) // random string to prevent caching
|
||||
xhr[0].send()
|
||||
}.bind(this)
|
||||
|
@ -457,14 +457,15 @@ function sendTelemetry(){
|
|||
xhr.open('POST', settings.url_telemetry+url_sep(settings.url_telemetry)+"r="+Math.random(), true);
|
||||
try{
|
||||
var fd = new FormData()
|
||||
fd.append('dl', dlStatus)
|
||||
fd.append('ispinfo', clientIp) //clientIp also contains ISP info
|
||||
fd.append('dl', dlStatus)
|
||||
fd.append('ul', ulStatus)
|
||||
fd.append('ping', pingStatus)
|
||||
fd.append('jitter', jitterStatus)
|
||||
fd.append('log', settings.telemetry_level>1?log:"")
|
||||
xhr.send(fd)
|
||||
}catch(ex){
|
||||
var postData = 'dl='+encodeURIComponent(dlStatus)+'&ul='+encodeURIComponent(ulStatus)+'&ping='+encodeURIComponent(pingStatus)+'&jitter='+encodeURIComponent(jitterStatus)+'&log='+encodeURIComponent(settings.telemetry_level>1?log:'')
|
||||
var postData = 'ispinfo='+encodeURIComponent(clientIp)+'dl='+encodeURIComponent(dlStatus)+'&ul='+encodeURIComponent(ulStatus)+'&ping='+encodeURIComponent(pingStatus)+'&jitter='+encodeURIComponent(jitterStatus)+'&log='+encodeURIComponent(settings.telemetry_level>1?log:'')
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
|
||||
xhr.send(postData)
|
||||
}
|
||||
|
|
2
speedtest_worker.min.js
vendored
2
speedtest_worker.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -2,6 +2,7 @@
|
|||
include_once('telemetry_settings.php');
|
||||
|
||||
$ip=($_SERVER['REMOTE_ADDR']);
|
||||
$ispinfo=($_POST["ispinfo"]);
|
||||
$ua=($_SERVER['HTTP_USER_AGENT']);
|
||||
$lang=""; if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) $lang=($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||
$dl=($_POST["dl"]);
|
||||
|
@ -12,8 +13,8 @@ $log=($_POST["log"]);
|
|||
|
||||
if($db_type=="mysql"){
|
||||
$conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename) or die("1");
|
||||
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?)") or die("2");
|
||||
$stmt->bind_param("ssssssss",$ip,$ua,$lang,$dl,$ul,$ping,$jitter,$log) or die("3");
|
||||
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?)") or die("2");
|
||||
$stmt->bind_param("sssssssss",$ip,$ispinfo,$ua,$lang,$dl,$ul,$ping,$jitter,$log) or die("3");
|
||||
$stmt->execute() or die("4");
|
||||
$stmt->close() or die("5");
|
||||
$conn->close() or die("6");
|
||||
|
@ -23,6 +24,7 @@ if($db_type=="mysql"){
|
|||
$conn->exec("
|
||||
CREATE TABLE IF NOT EXISTS `speedtest_users` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`ispinfo` text,
|
||||
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`ip` text NOT NULL,
|
||||
`ua` text NOT NULL,
|
||||
|
@ -34,8 +36,8 @@ if($db_type=="mysql"){
|
|||
`log` longtext
|
||||
);
|
||||
");
|
||||
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?)") or die("2");
|
||||
$stmt->execute(array($ip,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
|
||||
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?)") or die("2");
|
||||
$stmt->execute(array($ip,$ispinfo,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
|
||||
$conn = null;
|
||||
}elseif($db_type=="postgresql"){
|
||||
// Prepare connection parameters for db connection
|
||||
|
@ -45,8 +47,8 @@ if($db_type=="mysql"){
|
|||
$conn_password = "password=$PostgreSql_password";
|
||||
// Create db connection
|
||||
$conn = new PDO("pgsql:$conn_host;$conn_db;$conn_user;$conn_password") or die("1");
|
||||
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?)") or die("2");
|
||||
$stmt->execute(array($ip,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
|
||||
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?)") or die("2");
|
||||
$stmt->execute(array($ip,$ispinfo,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
|
||||
$conn = null;
|
||||
}
|
||||
elseif($db_type=="csv"){
|
||||
|
@ -55,6 +57,7 @@ elseif($db_type=="csv"){
|
|||
$date = date('Y-m-d H:i:s');
|
||||
$str = '"' . $date . '",';
|
||||
$str .= '"' . $ip . '",';
|
||||
$str .= '"' . $ispinfo . '",';
|
||||
$str .= '"' . $ua . '",';
|
||||
$str .= '"' . $dl . '",';
|
||||
$str .= '"' . $ul . '",';
|
||||
|
@ -63,11 +66,11 @@ elseif($db_type=="csv"){
|
|||
|
||||
// Set header if this is a new file
|
||||
if (!file_exists($Csv_File)) {
|
||||
$header = '"date","ip","ua","download","upload","ping","jitter"' . "\n";
|
||||
$header = '"date","ip","ispinfo","ua","download","upload","ping","jitter"' . "\n";
|
||||
file_put_contents($Csv_File, $header, FILE_APPEND);
|
||||
}
|
||||
|
||||
// Writting line to file
|
||||
// Write line to file
|
||||
file_put_contents($Csv_File, $str, FILE_APPEND);
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,12 +1,3 @@
|
|||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.7.0
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Aug 24, 2017 at 02:16 PM
|
||||
-- Server version: 10.1.25-MariaDB
|
||||
-- PHP Version: 7.1.7
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
SET AUTOCOMMIT = 0;
|
||||
START TRANSACTION;
|
||||
|
@ -32,6 +23,7 @@ CREATE TABLE `speedtest_users` (
|
|||
`id` int(11) NOT NULL,
|
||||
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`ip` text NOT NULL,
|
||||
`ispinfo` text,
|
||||
`ua` text NOT NULL,
|
||||
`lang` text NOT NULL,
|
||||
`dl` text,
|
||||
|
|
|
@ -42,6 +42,7 @@ CREATE TABLE speedtest_users (
|
|||
id integer NOT NULL,
|
||||
"timestamp" timestamp without time zone DEFAULT now() NOT NULL,
|
||||
ip text NOT NULL,
|
||||
ispinfo text,
|
||||
ua text NOT NULL,
|
||||
lang text NOT NULL,
|
||||
dl text,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
$db_type="mysql"; //Type of db: "mysql", "sqlite" or "postgresql" or "csv"
|
||||
$db_type="mysql"; //Type of db: "mysql", "sqlite", "postgresql" or "csv"
|
||||
|
||||
// Sqlite3 settings
|
||||
$Sqlite_db_file = "../telemetry.sql";
|
||||
|
|
Loading…
Reference in a new issue