2017-08-24 13:28:28 +00:00
|
|
|
<?php
|
2017-11-07 05:40:02 +00:00
|
|
|
include_once('telemetry_settings.php');
|
2019-01-30 09:16:28 +00:00
|
|
|
require 'idObfuscation.php';
|
2017-08-24 13:28:28 +00:00
|
|
|
|
|
|
|
$ip=($_SERVER['REMOTE_ADDR']);
|
2018-08-05 06:12:07 +00:00
|
|
|
$ispinfo=($_POST["ispinfo"]);
|
2018-08-07 09:55:25 +00:00
|
|
|
$extra=($_POST["extra"]);
|
2017-08-24 13:28:28 +00:00
|
|
|
$ua=($_SERVER['HTTP_USER_AGENT']);
|
2018-02-02 18:07:18 +00:00
|
|
|
$lang=""; if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) $lang=($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
2017-08-24 13:28:28 +00:00
|
|
|
$dl=($_POST["dl"]);
|
|
|
|
$ul=($_POST["ul"]);
|
|
|
|
$ping=($_POST["ping"]);
|
|
|
|
$jitter=($_POST["jitter"]);
|
|
|
|
$log=($_POST["log"]);
|
|
|
|
|
2019-09-28 06:22:14 +00:00
|
|
|
if($redact_ip_addresses){
|
|
|
|
$ip="0.0.0.0";
|
|
|
|
$ispinfo=preg_replace('/((2[0-4]|1\d|[1-9])?\d|25[0-5])(\.(?1)){3}/',"0.0.0.0",preg_replace('/(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:(?!$)|$)|\2))(?4){5}((?4){2}|((2[0-4]|1\d|[1-9])?\d|25[0-5])(\.(?7)){3})/i',"0.0.0.0",$ispinfo));
|
|
|
|
$log=preg_replace('/((2[0-4]|1\d|[1-9])?\d|25[0-5])(\.(?1)){3}/',"0.0.0.0",preg_replace('/(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:(?!$)|$)|\2))(?4){5}((?4){2}|((2[0-4]|1\d|[1-9])?\d|25[0-5])(\.(?7)){3})/i',"0.0.0.0",$log));
|
|
|
|
}
|
|
|
|
|
2019-06-30 05:03:06 +00:00
|
|
|
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, s-maxage=0');
|
|
|
|
header('Cache-Control: post-check=0, pre-check=0', false);
|
|
|
|
header('Pragma: no-cache');
|
|
|
|
|
2017-09-05 06:00:05 +00:00
|
|
|
if($db_type=="mysql"){
|
|
|
|
$conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename) or die("1");
|
2018-08-07 09:55:25 +00:00
|
|
|
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2");
|
|
|
|
$stmt->bind_param("ssssssssss",$ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log) or die("3");
|
2018-08-06 16:15:32 +00:00
|
|
|
$stmt->execute() or die("4");
|
2017-09-05 06:00:05 +00:00
|
|
|
$stmt->close() or die("5");
|
2019-01-30 09:16:28 +00:00
|
|
|
$id=$conn->insert_id;
|
|
|
|
echo "id ".($enable_id_obfuscation?obfuscateId($id):$id);
|
2017-09-05 06:00:05 +00:00
|
|
|
$conn->close() or die("6");
|
|
|
|
|
|
|
|
}elseif($db_type=="sqlite"){
|
2017-11-07 05:40:02 +00:00
|
|
|
$conn = new PDO("sqlite:$Sqlite_db_file") or die("1");
|
2017-09-05 06:00:05 +00:00
|
|
|
$conn->exec("
|
|
|
|
CREATE TABLE IF NOT EXISTS `speedtest_users` (
|
|
|
|
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
2018-08-05 06:12:07 +00:00
|
|
|
`ispinfo` text,
|
2018-08-07 09:55:25 +00:00
|
|
|
`extra` text,
|
2017-09-05 06:00:05 +00:00
|
|
|
`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
|
|
|
|
);
|
|
|
|
");
|
2018-08-07 09:55:25 +00:00
|
|
|
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2");
|
|
|
|
$stmt->execute(array($ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
|
2019-01-30 09:16:28 +00:00
|
|
|
$id=$conn->lastInsertId();
|
|
|
|
echo "id ".($enable_id_obfuscation?obfuscateId($id):$id);
|
2017-09-05 06:00:05 +00:00
|
|
|
$conn = null;
|
2017-11-07 05:40:02 +00:00
|
|
|
}elseif($db_type=="postgresql"){
|
|
|
|
// Prepare connection parameters for db connection
|
|
|
|
$conn_host = "host=$PostgreSql_hostname";
|
|
|
|
$conn_db = "dbname=$PostgreSql_databasename";
|
|
|
|
$conn_user = "user=$PostgreSql_username";
|
|
|
|
$conn_password = "password=$PostgreSql_password";
|
|
|
|
// Create db connection
|
|
|
|
$conn = new PDO("pgsql:$conn_host;$conn_db;$conn_user;$conn_password") or die("1");
|
2018-08-07 09:55:25 +00:00
|
|
|
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2");
|
|
|
|
$stmt->execute(array($ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
|
2019-01-30 09:16:28 +00:00
|
|
|
$id=$conn->lastInsertId();
|
|
|
|
echo "id ".($enable_id_obfuscation?obfuscateId($id):$id);
|
2017-11-07 05:40:02 +00:00
|
|
|
$conn = null;
|
2017-09-05 06:00:05 +00:00
|
|
|
}
|
2018-08-08 06:57:24 +00:00
|
|
|
else die("-1");
|
2017-09-05 06:00:05 +00:00
|
|
|
?>
|