mirror of
https://github.com/librespeed/speedtest.git
synced 2025-06-28 20:09:54 +00:00
* Initial implementation of ipinfo.io offline database * Removed unnecessary code * add: download ipinfo db during docker build * fixed workflow * rename warning in workflow * commit to trigger workflow * Refactor getIP * Improved UI * Updated docker version with 5.4 changes * Updated README.md * Added fallback in getIP in case the offline db is missing * Fixed typos * just md linting * Removed vscode stuff * Implemented fallback in getIP for PHP<8 (returns only the IP) * Updated doc.md * Fixed comments in telemetry_settings.php * New quick start video * Corrected image name in doc_docker.md * Replaced speedtest with just test in stats.php * docker documentation update * typo --------- Co-authored-by: Federico Dossena <info@fdossena.com> Co-authored-by: Stefan Stidl <stefan.stidl@ffg.at>
19 lines
546 B
PHP
Executable file
19 lines
546 B
PHP
Executable file
<?php
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
function getClientIp() {
|
|
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
|
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
|
} elseif (!empty($_SERVER['HTTP_X_REAL_IP'])) {
|
|
$ip = $_SERVER['HTTP_X_REAL_IP'];
|
|
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
|
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
|
$ip = preg_replace('/,.*/', '', $ip); # hosts are comma-separated, client is first
|
|
} else {
|
|
$ip = $_SERVER['REMOTE_ADDR'];
|
|
}
|
|
|
|
return preg_replace('/^::ffff:/', '', $ip);
|
|
}
|