telemetry.php 2.4 KB

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