Sat, 17 Nov 2018 19:44:39 +0100
Fix for missing coor info on fermentables during recipes import. Log when srm or ebc values are negatie during conversions. Load setup record in global.inc.php and make some variables available for PHP and JS.
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | <?php |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
3 | require($_SERVER['DOCUMENT_ROOT']."/config.php"); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
4 | require($_SERVER['DOCUMENT_ROOT']."/version.php"); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | #Connect to the database |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | if (! $connect) { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | } |
77
a9f8de2d7b2b
Fixed most charset problems. Added fpdf library. Added inventory pdf creation.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
11 | mysqli_set_charset($connect, "utf8" ); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
13 | $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c"); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
14 | $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"); |
61 | 15 | $rescapers = array("'"); |
16 | $rreplacements = array("\\'"); | |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
17 | $disallowed = array('visibleindex','uniqueid','boundindex','uid'); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
18 | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | // get data and store in a json array |
51 | 20 | $query = "SELECT * FROM recipes ORDER BY st_guide,st_letter,st_name,name"; |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
21 | if (isset($_POST['insert']) || isset($_POST['update'])) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
22 | if (isset($_POST['insert'])) { |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
23 | // INSERT COMMAND |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
24 | $sql = "INSERT INTO `recipes` SET "; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
25 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
26 | if (isset($_POST['update'])) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
27 | // UPDATE COMMAND |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
28 | $sql = "UPDATE `recipes` SET "; |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
29 | } |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
30 | // Basic settings |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
31 | $sql .= "st_name='" . mysqli_real_escape_string($connect, $_POST['st_name']); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
32 | $sql .= "', st_letter='" . mysqli_real_escape_string($connect, $_POST['st_letter']); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
33 | $sql .= "', st_guide='" . mysqli_real_escape_string($connect, $_POST['st_guide']); |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
34 | $sql .= "', st_type='" . mysqli_real_escape_string($connect, $_POST['st_type']); |
80
75b9227fb98c
Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
35 | $sql .= "', st_category='" . mysqli_real_escape_string($connect, $_POST['st_category']); |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
36 | $sql .= "', st_category_number='" . $_POST['st_category_number']; |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
37 | $sql .= "', st_og_min='" . $_POST['st_og_min']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
38 | $sql .= "', st_og_max='" . $_POST['st_og_max']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
39 | $sql .= "', st_fg_min='" . $_POST['st_fg_min']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
40 | $sql .= "', st_fg_max='" . $_POST['st_fg_max']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
41 | $sql .= "', st_ibu_min='" . $_POST['st_ibu_min']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
42 | $sql .= "', st_ibu_max='" . $_POST['st_ibu_max']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
43 | $sql .= "', st_color_min='" . $_POST['st_color_min']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
44 | $sql .= "', st_color_max='" . $_POST['st_color_max']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
45 | $sql .= "', st_carb_min='" . $_POST['st_carb_min']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
46 | $sql .= "', st_carb_max='" . $_POST['st_carb_max']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
47 | $sql .= "', st_abv_min='" . $_POST['st_abv_min']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
48 | $sql .= "', st_abv_max='" . $_POST['st_abv_max']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
49 | $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
50 | $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
51 | $sql .= "', type='" . $_POST['type']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
52 | $sql .= "', batch_size='" . $_POST['batch_size']; |
94
295c3af2a421
Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
80
diff
changeset
|
53 | $sql .= "', boil_size='" . $_POST['boil_size']; |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
54 | $sql .= "', boil_time='" . $_POST['boil_time']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
55 | $sql .= "', efficiency='" . $_POST['efficiency']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
56 | $sql .= "', est_og='" . $_POST['est_og']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
57 | $sql .= "', est_fg='" . $_POST['est_fg']; |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
58 | $sql .= "', est_abv='" . $_POST['est_abv']; |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
59 | $sql .= "', est_carb='" . $_POST['est_carb']; |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
60 | $sql .= "', est_color='" . $_POST['est_color']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
61 | $sql .= "', color_method='" . $_POST['color_method']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
62 | $sql .= "', est_ibu='" . $_POST['est_ibu']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
63 | $sql .= "', ibu_method='" . $_POST['ibu_method']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
64 | $sql .= "', mash_sparge_temp='" . $_POST['mash_sparge_temp']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
65 | $sql .= "', mash_ph='" . $_POST['mash_ph']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
66 | $sql .= "', mash_name='" . $_POST['mash_name']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
67 | syslog(LOG_NOTICE, $sql); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
68 | |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
69 | if (isset($_POST['fermentables'])) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
70 | $array = $_POST['fermentables']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
71 | foreach($array as $key => $item){ |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
72 | foreach ($disallowed as $disallowed_key) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
73 | unset($array[$key]["$disallowed_key"]); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
74 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
75 | } |
61 | 76 | syslog(LOG_NOTICE, "json_fermentables=: ".str_replace($rescapers,$rreplacements,json_encode($array))); |
77 | $sql .= "', json_fermentables='" . str_replace($rescapers,$rreplacements,json_encode($array)); | |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
78 | } |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
79 | |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
80 | if (isset($_POST['hops'])) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
81 | $array = $_POST['hops']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
82 | foreach($array as $key => $item){ |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
83 | foreach ($disallowed as $disallowed_key) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
84 | unset($array[$key]["$disallowed_key"]); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
85 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
86 | } |
61 | 87 | syslog(LOG_NOTICE, "json_hops: ".str_replace($rescapers,$rreplacements,json_encode($array))); |
88 | $sql .= "', json_hops='" . str_replace($rescapers,$rreplacements,json_encode($array)); | |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
89 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
90 | |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
91 | if (isset($_POST['miscs'])) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
92 | $array = $_POST['miscs']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
93 | foreach($array as $key => $item){ |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
94 | foreach ($disallowed as $disallowed_key) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
95 | unset($array[$key]["$disallowed_key"]); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
96 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
97 | } |
61 | 98 | syslog(LOG_NOTICE, "json_miscs: ".str_replace($rescapers,$rreplacements,json_encode($array))); |
99 | $sql .= "', json_miscs='" . str_replace($rescapers,$rreplacements,json_encode($array)); | |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
100 | } |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
101 | |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
102 | if (isset($_POST['yeasts'])) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
103 | $array = $_POST['yeasts']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
104 | foreach($array as $key => $item){ |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
105 | foreach ($disallowed as $disallowed_key) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
106 | unset($array[$key]["$disallowed_key"]); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
107 | } |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
108 | } |
61 | 109 | syslog(LOG_NOTICE, "json_yeasts: ". str_replace($rescapers,$rreplacements,json_encode($array))); |
110 | $sql .= "', json_yeasts='" . str_replace($rescapers,$rreplacements,json_encode($array)); | |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
111 | } |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
112 | |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
113 | if (isset($_POST['waters'])) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
114 | $array = $_POST['waters']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
115 | foreach($array as $key => $item){ |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
116 | foreach ($disallowed as $disallowed_key) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
117 | unset($array[$key]["$disallowed_key"]); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
118 | } |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
119 | } |
61 | 120 | syslog(LOG_NOTICE, "json_waters: ".str_replace($rescapers,$rreplacements,json_encode($array))); |
121 | $sql .= "', json_waters='" . str_replace($rescapers,$rreplacements,json_encode($array)); | |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
52
diff
changeset
|
122 | } |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
123 | |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
124 | if (isset($_POST['mashs'])) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
125 | $array = $_POST['mashs']; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
126 | foreach($array as $key => $item){ |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
127 | foreach ($disallowed as $disallowed_key) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
128 | unset($array[$key]["$disallowed_key"]); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
129 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
130 | } |
61 | 131 | syslog(LOG_NOTICE, "json_mashs: ".str_replace($rescapers,$rreplacements,json_encode($array))); |
132 | $sql .= "', json_mashs='" . str_replace($rescapers,$rreplacements,json_encode($array)); | |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
133 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
134 | |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
135 | if (isset($_POST['insert'])) { |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
136 | $sql .= "';"; |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
137 | } |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
138 | if (isset($_POST['update'])) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
139 | $sql .= "' WHERE record='" . $_POST['record'] . "';"; |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
140 | } |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
142 | $result = mysqli_query($connect, $sql); |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
143 | if (! $result) { |
61 | 144 | syslog(LOG_NOTICE, "db_recipes: result: ".mysqli_error($connect)); |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
145 | } else { |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
146 | if (isset($_POST['update'])) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
147 | syslog(LOG_NOTICE, "db_recipes: updated record ".$_POST['record']); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
148 | } else { |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
149 | $lastid = mysqli_insert_id($connect); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
150 | syslog(LOG_NOTICE, "db_recipes: inserted record ".$lastid); |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
151 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
152 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
153 | echo $result; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
154 | |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
155 | } else if (isset($_POST['delete'])) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
156 | // DELETE COMMAND |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
157 | $sql = "DELETE FROM `recipes` WHERE record='".$_POST['record']."';"; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
158 | $result = mysqli_query($connect, $sql); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
159 | if (! $result) { |
61 | 160 | syslog(LOG_NOTICE, "db_recipes: result: ".mysqli_error($connect)); |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
161 | } else { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
162 | syslog(LOG_NOTICE, "db_recipes: deleted record ".$_POST['record']); |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
163 | } |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
164 | echo $result; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | } else { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | // SELECT COMMAND |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | $recipes = '['; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
170 | $comma = FALSE; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
171 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | // Manual encode to JSON. |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
173 | if ($comma) { |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
174 | $recipes .= ','; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
175 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
176 | $comma = TRUE; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
177 | $recipes .= '{"record":' . $row['record']; |
51 | 178 | $recipes .= ',"st_guide":"' . str_replace($escapers, $replacements, $row['st_guide']); |
179 | $recipes .= '","st_letter":"' . str_replace($escapers, $replacements, $row['st_letter']); | |
180 | $recipes .= '","st_name":"' . str_replace($escapers, $replacements, $row['st_name']); | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
181 | $recipes .= '","st_type":"' . str_replace($escapers, $replacements, $row['st_type']); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
182 | $recipes .= '","st_category":"' . str_replace($escapers, $replacements, $row['st_category']); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
183 | $recipes .= '","st_category_number":' . floatval($row['st_category_number']); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
184 | $recipes .= ',"st_og_min":' . floatval($row['st_og_min']); |
51 | 185 | $recipes .= ',"st_og_max":' . floatval($row['st_og_max']); |
186 | $recipes .= ',"st_fg_min":' . floatval($row['st_fg_min']); | |
187 | $recipes .= ',"st_fg_max":' . floatval($row['st_fg_max']); | |
188 | $recipes .= ',"st_ibu_min":' . floatval($row['st_ibu_min']); | |
189 | $recipes .= ',"st_ibu_max":' . floatval($row['st_ibu_max']); | |
190 | $recipes .= ',"st_color_min":' . floatval($row['st_color_min']); | |
191 | $recipes .= ',"st_color_max":' . floatval($row['st_color_max']); | |
192 | $recipes .= ',"st_carb_min":' . floatval($row['st_carb_min']); | |
193 | $recipes .= ',"st_carb_max":' . floatval($row['st_carb_max']); | |
194 | $recipes .= ',"st_abv_min":' . floatval($row['st_abv_min']); | |
195 | $recipes .= ',"st_abv_max":' . floatval($row['st_abv_max']); | |
196 | $recipes .= ',"name":"' . str_replace($escapers, $replacements, $row['name']); | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
197 | $recipes .= '","notes":"' . str_replace($escapers, $replacements, $row['notes']); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
198 | $recipes .= '","type":"' . $row['type']; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
199 | $recipes .= '","batch_size":' . floatval($row['batch_size']); |
94
295c3af2a421
Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
80
diff
changeset
|
200 | $recipes .= ',"boil_size":' . floatval($row['boil_size']); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
201 | $recipes .= ',"boil_time":' . floatval($row['boil_time']); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
202 | $recipes .= ',"efficiency":' . floatval($row['efficiency']); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
203 | $recipes .= ',"est_og":' . floatval($row['est_og']); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
204 | $recipes .= ',"est_fg":' . floatval($row['est_fg']); |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
205 | $recipes .= ',"est_abv":' . floatval($row['est_abv']); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
206 | $recipes .= ',"est_carb":' . floatval($row['est_carb']); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
207 | $recipes .= ',"est_color":' . floatval($row['est_color']); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | $recipes .= ',"color_method":"' . $row['color_method']; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
209 | $recipes .= '","est_ibu":' . floatval($row['est_ibu']); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
210 | $recipes .= ',"ibu_method":"' . $row['ibu_method']; |
51 | 211 | $recipes .= '","mash_sparge_temp":' . $row['mash_sparge_temp']; |
212 | $recipes .= ',"mash_ph":' . $row['mash_ph']; | |
213 | $recipes .= ',"mash_name":"' . $row['mash_name']; | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
214 | $recipes .= '","fermentables":' . $row['json_fermentables']; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
215 | $recipes .= ',"hops":' . $row['json_hops']; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
216 | $recipes .= ',"miscs":' . $row['json_miscs']; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
217 | $recipes .= ',"yeasts":' . $row['json_yeasts']; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
218 | $recipes .= ',"waters":' . $row['json_waters']; |
51 | 219 | $recipes .= ',"mashs":' . $row['json_mashs']; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
220 | $recipes .= '}'; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
221 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | $recipes .= ']'; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
223 | header("Content-type: application/json"); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
224 | echo $recipes; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
225 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
226 | ?> |