-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert_data_3.php
69 lines (53 loc) · 1.33 KB
/
insert_data_3.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
header("Content-Type: application/json");
$hostname = "mysql3.gear.host";
$database = "shakefacility";
$user = "shakefacility";
$pass = "AD1_facilities";
$conn = mysqli_connect($hostname, $user, $pass, $database);
if (!$conn)
{
$response = array('status' => 105, 'message' => mysqli_connect_error());
echo json_encode($response);
exit(0);
}
$tkq = "SELECT token FROM token_list LIMIT 1";
$tkr = mysqli_query($conn, $tkq);
if (mysqli_num_rows($tkr) <= 0)
{
$response = array('status' => 100);
echo json_encode($response);
exit(0);
}
$tk_ref = mysqli_fetch_assoc($tkr);
if (!isset($_POST['token']))
{
$response = array('status' => 101);
echo json_encode($response);
exit(0);
}
$token=$_POST['token'];
if ($token != base64_encode($tk_ref['token']))
{
$response = array('status' => 102);
echo json_encode($response);
exit(0);
}
$starttime = $_POST['starttime'];
$endtime = $_POST['endtime'];
$intensity = $_POST['intensity'];
$pga = $_POST['pga'];
$pgv = $_POST['pgv'];
$inq = "INSERT INTO trace_data(starttime, endtime, intensity, pga, pgv) VALUES(" . $starttime . "," . $endtime . "," . $intensity . "," . $pga . "," . $pgv . ")";
if (mysqli_query($conn, $inq))
{
$response = array('status' => 4, 'message' => $inq);
}
else
{
$response = array('status' => 103);
}
echo json_encode($response);
mysqli_close($conn);
exit(0);
?>