
* Update README.md Added simple manual instructions * Link to docker documentation * Add basic docker compose example * add descriptive alt-text to GIF * Fix some typos and formatting * Updated Docker to use php8.2-apache as the upstream image. * Clean up apt lists after installation in Dockerfile * Update Dockerfile Co-authored-by: Quentame <polletquentin74@me.com> * fix typo * doc: sqlite db persistance explained * Create docker-publish.yml * Update docker-publish.yml * Update docker-publish.yml * fix action * switch docker image location * without image signing * remove signing * switch units to Mbit/s * move examples to folder * fix ipinfo parsing * fix regression on getIpinfo * removed trailing whitespaces * integrate ios favicon closes #400 * set single-server-full as index --------- Co-authored-by: Les W <30345058+leswaters@users.noreply.github.com> Co-authored-by: bt90 <btom1990@googlemail.com> Co-authored-by: An | Anton Röhm <18481195+AnTheMaker@users.noreply.github.com> Co-authored-by: 0kyn <0kyn.dev@gmail.com> Co-authored-by: Marc Zampetti <zampettim@users.noreply.github.com> Co-authored-by: Peter Dave Hello <hsu@peterdavehello.org> Co-authored-by: Quentame <polletquentin74@me.com> Co-authored-by: Stefan STIDL <stefan.stidl@ffg.at>
59 lines
1.4 KiB
PHP
Executable file
59 lines
1.4 KiB
PHP
Executable file
<?php
|
|
|
|
require_once 'telemetry_db.php';
|
|
|
|
/**
|
|
* @param int|float $d
|
|
*
|
|
* @return string
|
|
*/
|
|
function format($d)
|
|
{
|
|
if ($d < 10) {
|
|
return number_format($d, 2, '.', '');
|
|
}
|
|
if ($d < 100) {
|
|
return number_format($d, 1, '.', '');
|
|
}
|
|
|
|
return number_format($d, 0, '.', '');
|
|
}
|
|
|
|
/**
|
|
* @param array $speedtest
|
|
*
|
|
* @return array
|
|
*/
|
|
function formatSpeedtestData($speedtest)
|
|
{
|
|
// format values for the image
|
|
$speedtest['dl'] = format($speedtest['dl']);
|
|
$speedtest['ul'] = format($speedtest['ul']);
|
|
$speedtest['ping'] = format($speedtest['ping']);
|
|
$speedtest['jitter'] = format($speedtest['jitter']);
|
|
$speedtest['timestamp'] = $speedtest['timestamp'];
|
|
|
|
$ispinfo = json_decode($speedtest['ispinfo'], true)['processedString'];
|
|
$dash = strpos($ispinfo, '-');
|
|
if ($dash !== false) {
|
|
$ispinfo = substr($ispinfo, $dash + 2);
|
|
$par = strrpos($ispinfo, '(');
|
|
if ($par !== false) {
|
|
$ispinfo = substr($ispinfo, 0, $par);
|
|
}
|
|
} else {
|
|
$ispinfo = '';
|
|
}
|
|
|
|
$speedtest['ispinfo'] = $ispinfo;
|
|
|
|
return $speedtest;
|
|
}
|
|
|
|
$speedtest = getSpeedtestUserById($_GET['id']);
|
|
if (!is_array($speedtest)) {
|
|
echo '{}';
|
|
}
|
|
$speedtest = formatSpeedtestData($speedtest);
|
|
|
|
echo json_encode(array('timestamp'=>$speedtest['timestamp'],'download'=>$speedtest['dl'],'upload'=>$speedtest['ul'],'ping'=>$speedtest['ping'],'jitter'=>$speedtest['jitter'],'ispinfo'=>$speedtest['ispinfo']));
|