Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ results/idObfuscation_salt.php
backend/getIP_serverLocation.php
db-dir/
.vscode/
.DS_Store
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ RUN rm -f /usr/src/php.tar.xz /usr/src/php.tar.xz.asc \
&& apt autoremove -y \
&& rm -rf /var/lib/apt/lists/*

# Set the timezone
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Prepare files and folders
RUN mkdir -p /speedtest/

Expand Down
22 changes: 17 additions & 5 deletions results/telemetry_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
require_once 'idObfuscation.php';

define('TELEMETRY_SETTINGS_FILE', 'telemetry_settings.php');

$tz = getenv('TZ');
//Set timezone to UTC if Environment variables are not set
if ($tz !== false) {
// If the TZ environment variable exists, set the default timezone for PHP to its value
date_default_timezone_set($tz);
} else {
// If the TZ environment variable does not exist, set a default timezone or handle the error
// Set it to the UTC timezone
date_default_timezone_set('UTC');
}
/**
* @return PDO|false
*/
Expand Down Expand Up @@ -185,15 +194,18 @@ function insertSpeedtestUser($ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping,
}

try {
$currentTimestamp = new DateTime('now'); // This will automatically use the timezone configured in PHP
$formattedTimestamp = $currentTimestamp->format('Y-m-d H:i:s');

$stmt = $pdo->prepare(
'INSERT INTO speedtest_users
(ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log)
VALUES (?,?,?,?,?,?,?,?,?,?)'
(ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log,timestamp)
VALUES (?,?,?,?,?,?,?,?,?,?,?)' // Added the timestamp field here
);
$stmt->execute([
$ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping, $jitter, $log
$ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping, $jitter, $log, $formattedTimestamp // Added $formattedTimestamp in the execute parameters
]);
$id = $pdo->lastInsertId();
$id = $pdo->lastInsertId();
} catch (Exception $e) {
if($returnExceptionOnError){
return $e;
Expand Down