Thu, 12 Oct 2023 14:19:46 +0200
Version 0.3.44. Moved iSpindel Plato calculation from the php script to bmsd. This uses calibration data in the mon_ispindels table. Setup of this data will be done by the bmsapp applications. Default settings are stored in MySQL. From now on you don't need to store calibration data in the iSpindel.
<?php require($_SERVER['DOCUMENT_ROOT']."/config.php"); require($_SERVER['DOCUMENT_ROOT']."/version.php"); #Connect to the database $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); if (! $connect) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } mysqli_set_charset($connect, "utf8" ); $response = array( 'error' => false, 'msg' => 'Ok', ); if (isset($_POST['insert']) || isset($_POST['update'])) { if (isset($_POST['insert'])) { $sql = "INSERT INTO `profile_styles` SET "; } if (isset($_POST['update'])) { $sql = "UPDATE `profile_styles` SET "; } if (isset($_POST['uuid']) && (strlen($_POST['uuid']) == 36)) { $sql .= "uuid='" . $_POST['uuid']; } else { $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); $sql .= "uuid='" . $uuid; } $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']); $sql .= "', category='" . mysqli_real_escape_string($connect, $_POST['category']); $sql .= "', category_number='" . $_POST['category_number']; $sql .= "', style_letter='" . mysqli_real_escape_string($connect, $_POST['style_letter']); $sql .= "', style_guide='" . mysqli_real_escape_string($connect, $_POST['style_guide']); $sql .= "', type='" . $_POST['type']; $sql .= "', og_min='" . $_POST['og_min']; $sql .= "', og_max='" . $_POST['og_max']; $sql .= "', fg_min='" . $_POST['fg_min']; $sql .= "', fg_max='" . $_POST['fg_max']; $sql .= "', ibu_min='" . $_POST['ibu_min']; $sql .= "', ibu_max='" . $_POST['ibu_max']; $sql .= "', color_min='" . $_POST['color_min']; $sql .= "', color_max='" . $_POST['color_max']; $sql .= "', carb_min='" . $_POST['carb_min']; $sql .= "', carb_max='" . $_POST['carb_max']; $sql .= "', abv_min='" . $_POST['abv_min']; $sql .= "', abv_max='" . $_POST['abv_max']; $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); $sql .= "', profile='" . mysqli_real_escape_string($connect, $_POST['profile']); $sql .= "', ingredients='" . mysqli_real_escape_string($connect, $_POST['ingredients']); $sql .= "', examples='" . mysqli_real_escape_string($connect, $_POST['examples']); if (isset($_POST['insert'])) { $sql .= "';"; } if (isset($_POST['update'])) { $sql .= "' WHERE record='" . $_POST['record'] . "';"; } $result = mysqli_query($connect, $sql); if (! $result) { syslog(LOG_NOTICE, "db_profile_styles: ".$sql." result: ".mysqli_error($connect)); $response['error'] = true; $response['msg'] = "SQL fout: ".mysqli_error($connect); } exit(json_encode($response)); } else if (isset($_POST['delete'])) { // DELETE COMMAND $sql = "DELETE FROM `profile_styles` WHERE record='".$_POST['record']."';"; $result = mysqli_query($connect, $sql); if (! $result) { syslog(LOG_NOTICE, "db_profile_styles: ".$sql." result: ".mysqli_error($connect)); $response['error'] = true; $response['msg'] = "SQL fout: ".mysqli_error($connect); } exit(json_encode($response)); } else { // SELECT COMMAND $query = "SELECT * FROM profile_styles ORDER BY style_guide,style_letter,name"; $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $styles[] = array( 'record' => $row['record'], 'uuid' => $row['uuid'], 'name' => $row['name'], 'category' => $row['category'], 'category_number' => $row['category_number'], 'style_letter' => $row['style_letter'], 'style_guide' => $row['style_guide'], 'type' => $row['type'], 'og_min' => $row['og_min'], 'og_max' => $row['og_max'], 'fg_min' => $row['fg_min'], 'fg_max' => $row['fg_max'], 'ibu_min' => $row['ibu_min'], 'ibu_max' => $row['ibu_max'], 'color_min' => $row['color_min'], 'color_max' => $row['color_max'], 'carb_min' => $row['carb_min'], 'carb_max' => $row['carb_max'], 'abv_min' => $row['abv_min'], 'abv_max' => $row['abv_max'], 'notes' => $row['notes'], 'profile' => $row['profile'], 'ingredients' => $row['ingredients'], 'examples' => $row['examples'] ); } header("Content-type: application/json"); exit(json_encode($styles)); } syslog(LOG_NOTICE, "db_profile_styles: missing arguments"); $response['error'] = true; $response['msg'] = "missing arguments"; echo json_encode($response); ?>