Merge branch 'master' into docker
This commit is contained in:
commit
a0e95a3d1c
16
doc.md
16
doc.md
|
@ -1,7 +1,7 @@
|
||||||
# HTML5 Speedtest
|
# HTML5 Speedtest
|
||||||
|
|
||||||
> by Federico Dossena
|
> by Federico Dossena
|
||||||
> Version 4.3.1, August 25 2017
|
> Version 4.3.2, September 5 2017
|
||||||
> [https://github.com/adolfintel/speedtest/](https://github.com/adolfintel/speedtest/)
|
> [https://github.com/adolfintel/speedtest/](https://github.com/adolfintel/speedtest/)
|
||||||
|
|
||||||
|
|
||||||
|
@ -249,21 +249,23 @@ You need to start the test with your replacements like this:
|
||||||
w.postMessage('start {"url_dl": "newGarbageURL", "url_ul": "newEmptyURL", "url_ping": "newEmptyURL", "url_getIp": "newIpURL"}')
|
w.postMessage('start {"url_dl": "newGarbageURL", "url_ul": "newEmptyURL", "url_ping": "newEmptyURL", "url_getIp": "newIpURL"}')
|
||||||
```
|
```
|
||||||
## Telemetry
|
## Telemetry
|
||||||
Telemetry currently requires PHP and MySQL.
|
Telemetry currently requires PHP and either MySQL or SQLite.
|
||||||
To set up the telemetry, we need to do 4 things:
|
To set up the telemetry, we need to do 4 things:
|
||||||
* copy `telemetry.php`
|
* copy `telemetry.php`
|
||||||
* edit `telemetry.php` to add your database access credentials
|
* edit `telemetry.php` to add your database settings
|
||||||
* create the database
|
* create the database
|
||||||
* enable telemetry
|
* enable telemetry
|
||||||
|
|
||||||
### Creating the database
|
### Creating the database
|
||||||
At the moment, only MySQL is supported.
|
This step is only for MySQL. Skip this if you want to use SQLite.
|
||||||
Log into your database using phpMyAdmin or a similar software and import `telemetry.sql` into an empty database.
|
Log into your database using phpMyAdmin or a similar software and import `telemetry.sql` into an empty database.
|
||||||
If you see a table called `speedtest_users`, empty, you did it right.
|
If you see a table called `speedtest_users`, empty, you did it right.
|
||||||
|
|
||||||
### Configuring `telemetry.php`
|
### Configuring `telemetry.php`
|
||||||
Open telemetry.php with notepad or a similar text editor, and insert your database access credentials
|
Open telemetry.php with notepad or a similar text editor.
|
||||||
```
|
Set your preferred database, ``$db_type="mysql";`` or ``$db_type="sqlite";``
|
||||||
|
If you choose to use MySQL, you must also add your database credentials:
|
||||||
|
```php
|
||||||
$MySql_username="USERNAME"; //your database username
|
$MySql_username="USERNAME"; //your database username
|
||||||
$MySql_password="PASSWORD"; //your database password
|
$MySql_password="PASSWORD"; //your database password
|
||||||
$MySql_hostname="DB_HOSTNAME"; //database address, usually localhost\
|
$MySql_hostname="DB_HOSTNAME"; //database address, usually localhost\
|
||||||
|
@ -278,7 +280,7 @@ There are 3 levels:
|
||||||
* `full`: same as above, but also collects a log (10-150 Kb each, not recommended)
|
* `full`: same as above, but also collects a log (10-150 Kb each, not recommended)
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```
|
```js
|
||||||
w.postMessage('start {"telemetry_level":"basic"}')
|
w.postMessage('start {"telemetry_level":"basic"}')
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
$MySql_username="USERNAME";
|
$db_type="mysql"; //Type db mysql or sqlite
|
||||||
$MySql_password="PASSWORD";
|
|
||||||
$MySql_hostname="DB_HOSTNAME";
|
|
||||||
$MySql_databasename="DB_NAME";
|
|
||||||
|
|
||||||
$ip=($_SERVER['REMOTE_ADDR']);
|
$ip=($_SERVER['REMOTE_ADDR']);
|
||||||
$ua=($_SERVER['HTTP_USER_AGENT']);
|
$ua=($_SERVER['HTTP_USER_AGENT']);
|
||||||
|
@ -13,11 +10,42 @@ $ping=($_POST["ping"]);
|
||||||
$jitter=($_POST["jitter"]);
|
$jitter=($_POST["jitter"]);
|
||||||
$log=($_POST["log"]);
|
$log=($_POST["log"]);
|
||||||
|
|
||||||
$conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename) or die("1");
|
if($db_type=="mysql"){
|
||||||
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?)") or die("2");
|
$MySql_username="USERNAME";
|
||||||
$stmt->bind_param("ssssssss",$ip,$ua,$lang,$dl,$ul,$ping,$jitter,$log) or die("3");
|
$MySql_password="PASSWORD";
|
||||||
$stmt->execute() or die("4");
|
$MySql_hostname="DB_HOSTNAME";
|
||||||
$stmt->close() or die("5");
|
$MySql_databasename="DB_NAME";
|
||||||
$conn->close() or die("6");
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
$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->execute() or die("4");
|
||||||
|
$stmt->close() or die("5");
|
||||||
|
$conn->close() or die("6");
|
||||||
|
|
||||||
|
}elseif($db_type=="sqlite"){
|
||||||
|
|
||||||
|
$file_db = "../telemetry.sql";
|
||||||
|
|
||||||
|
$conn = new PDO("sqlite:$file_db") or die("1");
|
||||||
|
$conn->exec("
|
||||||
|
CREATE TABLE IF NOT EXISTS `speedtest_users` (
|
||||||
|
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`ip` text NOT NULL,
|
||||||
|
`ua` text NOT NULL,
|
||||||
|
`lang` text NOT NULL,
|
||||||
|
`dl` text,
|
||||||
|
`ul` text,
|
||||||
|
`ping` text,
|
||||||
|
`jitter` text,
|
||||||
|
`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");
|
||||||
|
$conn = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
Loading…
Reference in a new issue