www/includes/db_recipes.php

changeset 57
bb9a06aa9acd
parent 52
b1f2a893572f
child 60
dbbe408108ea
equal deleted inserted replaced
56:d4f4762e59b3 57:bb9a06aa9acd
12 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); 12 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
13 } 13 }
14 14
15 $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c"); 15 $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c");
16 $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"); 16 $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b");
17 $disallowed = array('visibleindex','uniqueid','boundindex','uid');
17 18
18 // get data and store in a json array 19 // get data and store in a json array
19 $query = "SELECT * FROM recipes ORDER BY st_guide,st_letter,st_name,name"; 20 $query = "SELECT * FROM recipes ORDER BY st_guide,st_letter,st_name,name";
20 if (isset($_GET['insert']) || isset($_GET['update'])) { 21 if (isset($_GET['insert']) || isset($_GET['update'])) {
21 if (isset($_GET['insert'])) { 22 if (isset($_GET['insert'])) {
56 $sql .= "', mash_ph='" . $_GET['mash_ph']; 57 $sql .= "', mash_ph='" . $_GET['mash_ph'];
57 $sql .= "', mash_name='" . $_GET['mash_name']; 58 $sql .= "', mash_name='" . $_GET['mash_name'];
58 59
59 syslog(LOG_NOTICE, $sql); // Log upto this part. 60 syslog(LOG_NOTICE, $sql); // Log upto this part.
60 61
61 syslog(LOG_NOTICE, "json_waters: " . json_encode($_GET['waters'])); 62 $array = $_GET['fermentables'];
62 $sql .= "', json_waters='" . json_encode($_GET['waters']); 63 foreach($array as $key => $item){
64 foreach ($disallowed as $disallowed_key) {
65 unset($array[$key]["$disallowed_key"]);
66 }
67 }
68 syslog(LOG_NOTICE, "json_fermentables: " . json_encode($array));
69 $sql .= "', json_fermentables='" . json_encode($array);
70
71 $array = $_GET['waters'];
72 foreach($array as $key => $item){
73 foreach ($disallowed as $disallowed_key) {
74 unset($array[$key]["$disallowed_key"]);
75 }
76 }
77 syslog(LOG_NOTICE, "json_waters: " . json_encode($array));
78 $sql .= "', json_waters='" . json_encode($array);
63 79
64 if (isset($_GET['insert'])) { 80 if (isset($_GET['insert'])) {
65 $sql .= "';"; 81 $sql .= "';";
66 } 82 }
67 if (isset($_GET['update'])) { 83 if (isset($_GET['update'])) {

mercurial