Mon, 20 Jan 2020 20:19:08 +0100
Checklist character encoding fixes.
<?php require_once('config.php'); $link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME); if (! $link) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } if (! mysqli_set_charset($link, "utf8" )) { echo "error"; return 1; } $rescapers = array("'"); $rreplacements = array("\\'"); date_default_timezone_set('Europe/Amsterdam'); if (isset($_GET["record"])) $record = $_GET["record"]; else $record = 78; $result = mysqli_query($link, "SELECT * FROM products WHERE record='".$record."'"); $row = mysqli_fetch_array($result); /* * Make this duplicate a fresh product. */ $sql = "INSERT INTO `products` SET "; $sql .= "name='" . mysqli_real_escape_string($link, $row['name']) . ' [duplicate]'; $sql .= "', uuid='" . str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); $sql .= "', code='" . mysqli_real_escape_string($link, $row['code']) . '-DuP'; $sql .= "', birth='" . date("Y-m-d"); $sql .= "', stage='1"; $sql .= "', notes='" . mysqli_real_escape_string($link, $row['notes']); $sql .= "', log_brew='0"; $sql .= "', log_fermentation='0"; $sql .= "', inventory_reduced='0"; $sql .= "', locked='0"; // Equipment $sql .= "', eq_name='" . mysqli_real_escape_string($link, $row['eq_name']); $sql .= "', eq_boil_size='" . $row['eq_boil_size']; $sql .= "', eq_batch_size='" . $row['eq_batch_size']; $sql .= "', eq_tun_volume='" . $row['eq_tun_volume']; $sql .= "', eq_tun_weight='" . $row['eq_tun_weight']; $sql .= "', eq_tun_specific_heat='" . $row['eq_tun_specific_heat']; $sql .= "', eq_tun_material='" . $row['eq_tun_material']; $sql .= "', eq_tun_height='" . $row['eq_tun_height']; $sql .= "', eq_top_up_water='" . $row['eq_top_up_water']; $sql .= "', eq_trub_chiller_loss='" . $row['eq_trub_chiller_loss']; $sql .= "', eq_evap_rate='" . $row['eq_evap_rate']; $sql .= "', eq_boil_time='" . $row['eq_boil_time']; $sql .= "', eq_calc_boil_volume='" . $row['eq_calc_boil_volume']; $sql .= "', eq_top_up_kettle='" . $row['eq_top_up_kettle']; $sql .= "', eq_hop_utilization='" . $row['eq_hop_utilization']; $sql .= "', eq_notes='" . mysqli_real_escape_string($link, $row['eq_notes']); $sql .= "', eq_lauter_volume='" . $row['eq_lauter_volume']; $sql .= "', eq_lauter_height='" . $row['eq_lauter_height']; $sql .= "', eq_lauter_deadspace='" . $row['eq_lauter_deadspace']; $sql .= "', eq_kettle_volume='" . $row['eq_kettle_volume']; $sql .= "', eq_kettle_height='" . $row['eq_kettle_height']; $sql .= "', eq_mash_volume='" . $row['eq_mash_volume']; $sql .= "', eq_mash_max='" . $row['eq_mash_max']; $sql .= "', eq_efficiency='" . $row['eq_efficiency']; // brewdate $sql .= "', brew_date_start=NULL"; $sql .= ", brew_mash_ph='0.0"; $sql .= "', brew_mash_sg='1.000"; $sql .= "', brew_sparge_ph='" . $row['brew_sparge_ph']; $sql .= "', brew_preboil_volume='0"; $sql .= "', brew_preboil_sg='0"; $sql .= "', brew_preboil_ph='0.0"; $sql .= "', brew_aboil_volume='0"; $sql .= "', brew_aboil_sg='0"; $sql .= "', brew_aboil_ph='0.0"; $sql .= "', brew_aboil_efficiency='0"; $sql .= "', brew_cooling_method='" . $row['brew_cooling_method']; $sql .= "', brew_cooling_time='0"; $sql .= "', brew_cooling_to='" . $row['brew_cooling_to']; $sql .= "', brew_whirlpool9='" . $row['brew_whirlpool9']; $sql .= "', brew_whirlpool7='" . $row['brew_whirlpool7']; $sql .= "', brew_whirlpool6='" . $row['brew_whirlpool6']; $sql .= "', brew_whirlpool2='" . $row['brew_whirlpool2']; $sql .= "', brew_aeration_time='" . $row['brew_aeration_time']; $sql .= "', brew_aeration_speed='" . $row['brew_aeration_speed']; $sql .= "', brew_aeration_type='" . $row['brew_aeration_type']; $sql .= "', brew_fermenter_volume='" . $row['brew_fermenter_volume']; $sql .= "', brew_fermenter_extrawater='" . $row['brew_fermenter_extrawater']; $sql .= "', brew_fermenter_tcloss='" . $row['brew_fermenter_tcloss']; $sql .= "', brew_fermenter_sg='0"; $sql .= "', brew_fermenter_ibu='0"; $sql .= "', brew_fermenter_color='0"; $sql .= "', brew_date_end=NULL"; $sql .= ", og='0"; $sql .= "', fg='0"; $sql .= "', primary_start_temp='0"; $sql .= "', primary_max_temp='0"; $sql .= "', primary_end_temp='0"; $sql .= "', primary_end_date=NULL"; $sql .= ", primary_end_sg='0"; $sql .= "', secondary_temp='0"; $sql .= "', secondary_end_sg='0"; $sql .= "', secondary_end_date=NULL"; $sql .= ", tertiary_temp='0"; $sql .= "', package_date=NULL"; $sql .= ", package_volume='" . $row['package_volume']; $sql .= "', package_infuse_amount='" . $row['package_infuse_amount']; $sql .= "', package_infuse_abv='" . $row['package_infuse_abv']; $sql .= "', package_infuse_notes='" . mysqli_real_escape_string($link, $row['package_infuse_notes']); $sql .= "', package_abv='0"; $sql .= "', package_ph='0"; $sql .= "', bottle_amount='0"; $sql .= "', bottle_carbonation='" . $row['bottle_carbonation']; $sql .= "', bottle_priming_water='" . $row['bottle_priming_water']; $sql .= "', bottle_priming_amount='0"; $sql .= "', bottle_carbonation_temp='" . $row['bottle_carbonation_temp']; $sql .= "', keg_amount='0"; $sql .= "', keg_carbonation='" . $row['keg_carbonation']; $sql .= "', keg_priming_water='" . $row['keg_priming_water']; $sql .= "', keg_priming_amount='0"; $sql .= "', keg_carbonation_temp='" . $row['keg_carbonation_temp']; $sql .= "', keg_forced_carb='" . $row['keg_forced_carb']; $sql .= "', keg_pressure='" . $row['keg_pressure']; $sql .= "', taste_notes='"; $sql .= "', taste_rate='0"; $sql .= "', taste_date=NULL"; $sql .= ", taste_color='"; $sql .= "', taste_transparency='"; $sql .= "', taste_head='"; $sql .= "', taste_aroma='"; $sql .= "', taste_taste='"; $sql .= "', taste_mouthfeel='"; $sql .= "', taste_aftertaste='"; // Style $sql .= "', st_name='" . mysqli_real_escape_string($link, $row['st_name']); $sql .= "', st_letter='" . mysqli_real_escape_string($link, $row['st_letter']); $sql .= "', st_guide='" . mysqli_real_escape_string($link, $row['st_guide']); $sql .= "', st_type='" . $row['st_type']; $sql .= "', st_category='" . mysqli_real_escape_string($link, $row['st_category']); $sql .= "', st_category_number='" . $row['st_category_number']; $sql .= "', st_og_min='" . $row['st_og_min']; $sql .= "', st_og_max='" . $row['st_og_max']; $sql .= "', st_fg_min='" . $row['st_fg_min']; $sql .= "', st_fg_max='" . $row['st_fg_max']; $sql .= "', st_ibu_min='" . $row['st_ibu_min']; $sql .= "', st_ibu_max='" . $row['st_ibu_max']; $sql .= "', st_color_min='" . $row['st_color_min']; $sql .= "', st_color_max='" . $row['st_color_max']; $sql .= "', st_carb_min='" . $row['st_carb_min']; $sql .= "', st_carb_max='" . $row['st_carb_max']; $sql .= "', st_abv_min='" . $row['st_abv_min']; $sql .= "', st_abv_max='" . $row['st_abv_max']; $sql .= "', type='" . $row['type']; $sql .= "', batch_size='" . $row['batch_size']; $sql .= "', boil_size='" . $row['boil_size']; $sql .= "', boil_time='" . $row['boil_time']; $sql .= "', efficiency='" . $row['efficiency']; $sql .= "', est_og='0.000"; $sql .= "', est_fg='0.000"; $sql .= "', est_abv='0.0"; $sql .= "', est_carb='0"; $sql .= "', est_color='0"; $sql .= "', color_method='" . $row['color_method']; $sql .= "', est_ibu='0"; $sql .= "', ibu_method='" . $row['ibu_method']; $sql .= "', sparge_temp='" . $row['sparge_temp']; $sql .= "', sparge_ph='" . $row['sparge_ph']; $sql .= "', sparge_volume='" . $row['sparge_volume']; $sql .= "', sparge_source='" . $row['sparge_source']; $sql .= "', sparge_acid_type='" . $row['sparge_acid_type']; $sql .= "', sparge_acid_perc='" . $row['sparge_acid_perc']; $sql .= "', sparge_acid_amount='0"; $sql .= "', mash_ph='" . $row['mash_ph']; $sql .= "', mash_name='" . $row['mash_name']; $sql .= "', calc_acid='" . $row['calc_acid']; $sql .= "', w1_name='" . mysqli_real_escape_string($link, $row['w1_name']); $sql .= "', w1_amount='" . $row['w1_amount']; $sql .= "', w1_calcium='" . $row['w1_calcium']; $sql .= "', w1_sulfate='" . $row['w1_sulfate']; $sql .= "', w1_chloride='" . $row['w1_chloride']; $sql .= "', w1_sodium='" . $row['w1_sodium']; $sql .= "', w1_magnesium='" . $row['w1_magnesium']; $sql .= "', w1_total_alkalinity='" . $row['w1_total_alkalinity']; $sql .= "', w1_ph='" . $row['w1_ph']; $sql .= "', w1_cost='" . $row['w1_cost']; $sql .= "', w2_name='" . mysqli_real_escape_string($link, $row['w2_name']); $sql .= "', w2_amount='" . $row['w2_amount']; $sql .= "', w2_calcium='" . $row['w2_calcium']; $sql .= "', w2_sulfate='" . $row['w2_sulfate']; $sql .= "', w2_chloride='" . $row['w2_chloride']; $sql .= "', w2_sodium='" . $row['w2_sodium']; $sql .= "', w2_magnesium='" . $row['w2_magnesium']; $sql .= "', w2_total_alkalinity='" . $row['w2_total_alkalinity']; $sql .= "', w2_ph='" . $row['w2_ph']; $sql .= "', w2_cost='" . $row['w2_cost']; $sql .= "', wa_acid_name='" . $row['wa_acid_name']; $sql .= "', wa_acid_perc='" . $row['wa_acid_perc']; $sql .= "', wa_base_name='" . $row['wa_base_name']; $sql .= "', starter_enable='" . $row['starter_enable']; $sql .= "', starter_type='" . $row['starter_type']; $sql .= "', starter_sg='" . $row['starter_sg']; $sql .= "', starter_viability='97"; $sql .= "', prop1_type='" . $row['prop1_type']; $sql .= "', prop1_volume='" . $row['prop1_volume']; $sql .= "', prop2_type='" . $row['prop2_type']; $sql .= "', prop2_volume='" . $row['prop2_volume']; $sql .= "', prop3_type='" . $row['prop3_type']; $sql .= "', prop3_volume='" . $row['prop3_volume']; $sql .= "', prop4_type='" . $row['prop4_type']; $sql .= "', prop4_volume='" . $row['prop4_volume']; $sql .= "', json_fermentables='" . str_replace($rescapers,$rreplacements,$row['json_fermentables']); $sql .= "', json_hops='" . str_replace($rescapers,$rreplacements,$row['json_hops']); $sql .= "', json_miscs='" . str_replace($rescapers,$rreplacements,$row['json_miscs']); $sql .= "', json_yeasts='" . str_replace($rescapers,$rreplacements,$row['json_yeasts']); $sql .= "', json_mashs='" . str_replace($rescapers,$rreplacements,$row['json_mashs']); $sql .= "';"; syslog(LOG_NOTICE, $sql); $result = mysqli_query($link, $sql); if (! $result) { syslog(LOG_NOTICE, "db_product: result: ".mysqli_error($link)); } else { $lastid = mysqli_insert_id($link); syslog(LOG_NOTICE, "db_product: inserted record ".$lastid); } echo "<script>window.close();</script>"; exit;