6 #Connect to the database |
6 #Connect to the database |
7 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); |
7 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); |
8 if (! $connect) { |
8 if (! $connect) { |
9 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); |
9 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); |
10 } |
10 } |
|
11 |
|
12 $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c"); |
|
13 $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"); |
11 |
14 |
12 // get data and store in a json array |
15 // get data and store in a json array |
13 $query = "SELECT * FROM profile_mash ORDER BY name"; |
16 $query = "SELECT * FROM profile_mash ORDER BY name"; |
14 if (isset($_GET['insert'])) { |
17 if (isset($_GET['insert'])) { |
15 // INSERT COMMAND |
18 // INSERT COMMAND |
60 if ($comma) { |
63 if ($comma) { |
61 $mashprofiles .= ','; |
64 $mashprofiles .= ','; |
62 } |
65 } |
63 $comma = TRUE; |
66 $comma = TRUE; |
64 $mashprofiles .= '{"record":' . $row['record']; |
67 $mashprofiles .= '{"record":' . $row['record']; |
65 $mashprofiles .= ',"name":"' . $row['name']; |
68 $mashprofiles .= ',"name":"' . str_replace($escapers, $replacements, $row['name']); |
66 $mashprofiles .= '","notes":"' . $row['notes']; |
69 $mashprofiles .= '","notes":"' . str_replace($escapers, $replacements, $row['notes']); |
67 $mashprofiles .= '","steps":' . $row['steps']; |
70 $mashprofiles .= '","steps":' . $row['steps']; |
68 $mashprofiles .= '}'; |
71 $mashprofiles .= '}'; |
69 } |
72 } |
70 $mashprofiles .= ']'; |
73 $mashprofiles .= ']'; |
71 header("Content-type: application/json"); |
74 header("Content-type: application/json"); |