Tue, 03 Mar 2020 17:15:56 +0100
Fixed starter production date tooltip. Upgraded jqwidgets from version 8.1.4 to 9.0.0
303 | 1 | <?php |
2 | require_once('config.php'); | |
3 | ||
4 | $link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME); | |
5 | if (! $link) { | |
6 | die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); | |
7 | } | |
8 | if (! mysqli_set_charset($link, "utf8" )) { | |
9 | echo "error"; | |
10 | return 1; | |
11 | } | |
12 | ||
305 | 13 | $rescapers = array("'"); |
14 | $rreplacements = array("\\'"); | |
15 | ||
303 | 16 | date_default_timezone_set('Europe/Amsterdam'); |
17 | if (isset($_GET["record"])) | |
18 | $record = $_GET["record"]; | |
19 | else | |
20 | $record = 78; | |
21 | $result = mysqli_query($link, "SELECT * FROM recipes WHERE record='".$record."'"); | |
22 | $row = mysqli_fetch_array($result); | |
23 | ||
24 | /* | |
25 | * Make this duplicate a fresh recipe. | |
26 | */ | |
27 | $sql = "INSERT INTO `recipes` SET "; | |
28 | $sql .= "name='" . mysqli_real_escape_string($link, $row['name']) . ' [duplicate]'; | |
29 | $sql .= "', uuid='" . str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); | |
30 | $sql .= "', notes='" . mysqli_real_escape_string($link, $row['notes']); | |
31 | $sql .= "', locked='0"; | |
32 | $sql .= "', st_name='" . mysqli_real_escape_string($link, $row['st_name']); | |
33 | $sql .= "', st_letter='" . mysqli_real_escape_string($link, $row['st_letter']); | |
34 | $sql .= "', st_guide='" . mysqli_real_escape_string($link, $row['st_guide']); | |
35 | $sql .= "', st_type='" . $row['st_type']; | |
36 | $sql .= "', st_category='" . mysqli_real_escape_string($link, $row['st_category']); | |
37 | $sql .= "', st_category_number='" . $row['st_category_number']; | |
38 | $sql .= "', st_og_min='" . $row['st_og_min']; | |
39 | $sql .= "', st_og_max='" . $row['st_og_max']; | |
40 | $sql .= "', st_fg_min='" . $row['st_fg_min']; | |
41 | $sql .= "', st_fg_max='" . $row['st_fg_max']; | |
42 | $sql .= "', st_ibu_min='" . $row['st_ibu_min']; | |
43 | $sql .= "', st_ibu_max='" . $row['st_ibu_max']; | |
44 | $sql .= "', st_color_min='" . $row['st_color_min']; | |
45 | $sql .= "', st_color_max='" . $row['st_color_max']; | |
46 | $sql .= "', st_carb_min='" . $row['st_carb_min']; | |
47 | $sql .= "', st_carb_max='" . $row['st_carb_max']; | |
48 | $sql .= "', st_abv_min='" . $row['st_abv_min']; | |
49 | $sql .= "', st_abv_max='" . $row['st_abv_max']; | |
50 | $sql .= "', type='" . $row['type']; | |
51 | $sql .= "', batch_size='" . $row['batch_size']; | |
52 | $sql .= "', boil_size='" . $row['boil_size']; | |
53 | $sql .= "', boil_time='" . $row['boil_time']; | |
54 | $sql .= "', efficiency='" . $row['efficiency']; | |
55 | $sql .= "', est_og='" . $row['est_og']; | |
56 | $sql .= "', est_fg='" . $row['est_fg']; | |
57 | $sql .= "', est_abv='" . $row['est_abv']; | |
58 | $sql .= "', est_carb='" . $row['est_carb']; | |
59 | $sql .= "', est_color='" . $row['est_color']; | |
60 | $sql .= "', color_method='" . $row['color_method']; | |
61 | $sql .= "', est_ibu='" . $row['est_ibu']; | |
62 | $sql .= "', ibu_method='" . $row['ibu_method']; | |
63 | $sql .= "', sparge_temp='" . $row['sparge_temp']; | |
64 | $sql .= "', sparge_ph='" . $row['sparge_ph']; | |
65 | $sql .= "', sparge_volume='" . $row['sparge_volume']; | |
66 | $sql .= "', sparge_source='" . $row['sparge_source']; | |
67 | $sql .= "', sparge_acid_type='" . $row['sparge_acid_type']; | |
68 | $sql .= "', sparge_acid_perc='" . $row['sparge_acid_perc']; | |
69 | $sql .= "', sparge_acid_amount='0"; | |
70 | $sql .= "', mash_ph='" . $row['mash_ph']; | |
71 | $sql .= "', mash_name='" . $row['mash_name']; | |
72 | $sql .= "', calc_acid='" . $row['calc_acid']; | |
73 | $sql .= "', w1_name='" . mysqli_real_escape_string($link, $row['w1_name']); | |
74 | $sql .= "', w1_amount='" . $row['w1_amount']; | |
75 | $sql .= "', w1_calcium='" . $row['w1_calcium']; | |
76 | $sql .= "', w1_sulfate='" . $row['w1_sulfate']; | |
77 | $sql .= "', w1_chloride='" . $row['w1_chloride']; | |
78 | $sql .= "', w1_sodium='" . $row['w1_sodium']; | |
79 | $sql .= "', w1_magnesium='" . $row['w1_magnesium']; | |
80 | $sql .= "', w1_total_alkalinity='" . $row['w1_total_alkalinity']; | |
81 | $sql .= "', w1_ph='" . $row['w1_ph']; | |
82 | $sql .= "', w1_cost='" . $row['w1_cost']; | |
83 | $sql .= "', w2_name='" . mysqli_real_escape_string($link, $row['w2_name']); | |
84 | $sql .= "', w2_amount='" . $row['w2_amount']; | |
85 | $sql .= "', w2_calcium='" . $row['w2_calcium']; | |
86 | $sql .= "', w2_sulfate='" . $row['w2_sulfate']; | |
87 | $sql .= "', w2_chloride='" . $row['w2_chloride']; | |
88 | $sql .= "', w2_sodium='" . $row['w2_sodium']; | |
89 | $sql .= "', w2_magnesium='" . $row['w2_magnesium']; | |
90 | $sql .= "', w2_total_alkalinity='" . $row['w2_total_alkalinity']; | |
91 | $sql .= "', w2_ph='" . $row['w2_ph']; | |
92 | $sql .= "', w2_cost='" . $row['w2_cost']; | |
93 | $sql .= "', wa_acid_name='" . $row['wa_acid_name']; | |
94 | $sql .= "', wa_acid_perc='" . $row['wa_acid_perc']; | |
95 | $sql .= "', wa_base_name='" . $row['wa_base_name']; | |
305 | 96 | $sql .= "', json_fermentables='" . str_replace($rescapers,$rreplacements,$row['json_fermentables']); |
97 | $sql .= "', json_hops='" . str_replace($rescapers,$rreplacements,$row['json_hops']); | |
98 | $sql .= "', json_miscs='" . str_replace($rescapers,$rreplacements,$row['json_miscs']); | |
99 | $sql .= "', json_yeasts='" . str_replace($rescapers,$rreplacements,$row['json_yeasts']); | |
100 | $sql .= "', json_mashs='" . str_replace($rescapers,$rreplacements,$row['json_mashs']); | |
303 | 101 | $sql .= "';"; |
102 | syslog(LOG_NOTICE, $sql); | |
103 | ||
104 | $result = mysqli_query($link, $sql); | |
105 | if (! $result) { | |
106 | syslog(LOG_NOTICE, "rec_duplicate: result: ".mysqli_error($link)); | |
107 | } else { | |
108 | $lastid = mysqli_insert_id($link); | |
109 | syslog(LOG_NOTICE, "rec_duplicate: inserted record ".$lastid); | |
110 | } | |
111 | echo "<script>window.close();</script>"; | |
112 | exit; |