-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_old.php
54 lines (44 loc) · 1.1 KB
/
index_old.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
<?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);
}
if (!isset($_GET['qnum']))
{
$response = array('status' => 104);
echo json_encode($response);
exit(0);
}
switch($_GET['qnum'])
{
case 0:
$trq = "SELECT starttime, endtime, intensity, pga, pgv FROM trace_data ORDER BY trace_id DESC LIMIT 1";
$trr = mysqli_query($conn, $trq);
if (mysqli_num_rows($trr) <= 0)
{
$response = array('status' => 106);
echo json_encode($response);
exit(0);
}
$tr_row = mysqli_fetch_assoc($trr);
$response = array( 'status' => 4,
'starttime' => $tr_row['starttime'],
'endtime' => $tr_row['endtime'],
'intensity' => $tr_row['intensity'],
'pga' => $tr_row['pga'],
'pgv' => $tr_row['pgv']);
echo json_encode($response);
break;
default:
break;
}
mysqli_close($conn);
?>