telemetry.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. include_once('telemetry_settings.php');
  3. require 'idObfuscation.php';
  4. $ip=($_SERVER['REMOTE_ADDR']);
  5. $ispinfo=($_POST["ispinfo"]);
  6. $extra=($_POST["extra"]);
  7. $ua=($_SERVER['HTTP_USER_AGENT']);
  8. $lang=""; if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) $lang=($_SERVER['HTTP_ACCEPT_LANGUAGE']);
  9. $dl=($_POST["dl"]);
  10. $ul=($_POST["ul"]);
  11. $ping=($_POST["ping"]);
  12. $jitter=($_POST["jitter"]);
  13. $log=($_POST["log"]);
  14. header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, s-maxage=0');
  15. header('Cache-Control: post-check=0, pre-check=0', false);
  16. header('Pragma: no-cache');
  17. if($db_type=="mysql"){
  18. $conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename) or die("1");
  19. $stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2");
  20. $stmt->bind_param("ssssssssss",$ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log) or die("3");
  21. $stmt->execute() or die("4");
  22. $stmt->close() or die("5");
  23. $id=$conn->insert_id;
  24. echo "id ".($enable_id_obfuscation?obfuscateId($id):$id);
  25. $conn->close() or die("6");
  26. }elseif($db_type=="sqlite"){
  27. $conn = new PDO("sqlite:$Sqlite_db_file") or die("1");
  28. $conn->exec("
  29. CREATE TABLE IF NOT EXISTS `speedtest_users` (
  30. `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  31. `ispinfo` text,
  32. `extra` text,
  33. `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  34. `ip` text NOT NULL,
  35. `ua` text NOT NULL,
  36. `lang` text NOT NULL,
  37. `dl` text,
  38. `ul` text,
  39. `ping` text,
  40. `jitter` text,
  41. `log` longtext
  42. );
  43. ");
  44. $stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2");
  45. $stmt->execute(array($ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
  46. $id=$conn->lastInsertId();
  47. echo "id ".($enable_id_obfuscation?obfuscateId($id):$id);
  48. $conn = null;
  49. }elseif($db_type=="postgresql"){
  50. // Prepare connection parameters for db connection
  51. $conn_host = "host=$PostgreSql_hostname";
  52. $conn_db = "dbname=$PostgreSql_databasename";
  53. $conn_user = "user=$PostgreSql_username";
  54. $conn_password = "password=$PostgreSql_password";
  55. // Create db connection
  56. $conn = new PDO("pgsql:$conn_host;$conn_db;$conn_user;$conn_password") or die("1");
  57. $stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2");
  58. $stmt->execute(array($ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
  59. $id=$conn->lastInsertId();
  60. echo "id ".($enable_id_obfuscation?obfuscateId($id):$id);
  61. $conn = null;
  62. }
  63. else die("-1");
  64. ?>