speedtest/store.php

28 lines
961 B
PHP
Raw Normal View History

2017-08-06 18:43:07 +00:00
<?php
2017-08-07 17:42:43 +00:00
include("config.php");
2017-08-06 18:43:07 +00:00
if (isset($_POST["ip"]) && isset($_POST["down"]) && isset($_POST["up"]) && isset($_POST["ping"]) && isset($_POST["jitter"])) {
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = 'INSERT INTO speedtest(ip, down, up, ping, jitter, ua) VALUES ("' . mysqli_real_escape_string($conn, $_POST['ip']) . '", "' . mysqli_real_escape_string($conn, $_POST['down']) . '", "' . mysqli_real_escape_string($conn, $_POST['up']) . '", "' . mysqli_real_escape_string($conn, $_POST['ping']) . '", "' . mysqli_real_escape_string($conn, $_POST['jitter']) . '", "' . mysqli_real_escape_string($conn, $_SERVER['HTTP_USER_AGENT']) . '");';
if (!mysqli_query($conn, $sql)) {
die('Error: ' . mysqli_error($conn));
}
mysqli_close($conn);
echo "OK";
} else {
header('HTTP/1.0 400 Bad Request');
}