www/upl_yeasts.php

Thu, 10 Feb 2022 22:15:10 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 10 Feb 2022 22:15:10 +0100
changeset 785
aa79acfdf8a9
parent 311
f6fafccd8a6d
permissions
-rw-r--r--

Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.

311
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 require_once('config.php');
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 require("version.php");
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 require("includes/formulas.php");
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 $target_dir = "tmp/";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 $uploadOk = 1;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 // Check if file already exists
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 if (file_exists($target_file)) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 echo "Fout 1: bestand bestaat al. ";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 $uploadOk = 0;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 // Check file size
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 if ($_FILES["fileToUpload"]["size"] > 500000 && $uploadOk) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 echo "Fout 2: het bestand is te groot. ";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 $uploadOk = 0;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 // Allow certain file formats
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 if ($imageFileType != "xml" && $uploadOk) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 echo "Fout 3: alleen XML bestanden toegestaan. ";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 $uploadOk = 0;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 // Check if $uploadOk is set to 0 by an error
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 if ($uploadOk == 0) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 exit;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 echo "Verwerken bestand ". basename( $_FILES["fileToUpload"]["name"]). "<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 } else {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 echo "Fout 4: er ging iets fout met de upload.";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 exit;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 $db = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 if (! $db) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 echo "Fout 5: ".mysqli_connect_errno()." ".mysqli_connect_error();
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 exit;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 mysqli_set_charset($db, "utf8" );
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 date_default_timezone_set('Europe/Amsterdam');
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 $imported = 0;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 $yeasts = simplexml_load_file($target_file);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 foreach ($yeasts->YEAST as $yeast) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53
785
aa79acfdf8a9 Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.
Michiel Broek <mbroek@mbse.eu>
parents: 311
diff changeset
54 $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid'));
aa79acfdf8a9 Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.
Michiel Broek <mbroek@mbse.eu>
parents: 311
diff changeset
55 $sql = "INSERT INTO inventory_yeasts SET uuid='" . $uuid;
aa79acfdf8a9 Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.
Michiel Broek <mbroek@mbse.eu>
parents: 311
diff changeset
56 $sql .= "', name='" . mysqli_real_escape_string($db, $yeast->NAME);
311
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 if ($yeast->TYPE == 'Lager')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 $sql .= "', type='0";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 else if ($yeast->TYPE == 'Ale')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 $sql .= "', type='1";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 else if ($yeast->TYPE == 'Wheat')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 $sql .= "', type='2";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 else if ($yeast->TYPE == 'Wine')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 $sql .= "', type='3";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 else if ($yeast->TYPE == 'Champagne')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 $sql .= "', type='4";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 else
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 echo "Unknown TYPE " . $yeast->TYPE . "<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 if ($yeast->FORM == 'Liquid')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 $sql .= "', form='0";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 else if ($yeast->FORM == 'Dry')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 $sql .= "', form='1";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 else if ($yeast->FORM == 'Slant')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 $sql .= "', form='2";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 else if ($yeast->FORM == 'Culture')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 $sql .= "', form='3";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 else if ($yeast->FORM == 'Frozen')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 $sql .= "', form='4";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 else if ($yeast->FORM == 'Bottle')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 $sql .= "', form='5";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 else
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 echo "Unknown FORM " . $yeast->FORM . "<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 $sql .= "', laboratory='" . mysqli_real_escape_string($db, $yeast->LABORATORY);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 $sql .= "', product_id='" . mysqli_real_escape_string($db, $yeast->PRODUCT_ID);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 if ($yeast->MIN_TEMPERATURE)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 $sql .= "', min_temperature='" . floatval($yeast->MIN_TEMPERATURE);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 if ($yeast->MAX_TEMPERATURE)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 $sql .= "', max_temperature='" . floatval($yeast->MAX_TEMPERATURE);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 if ($yeast->FLOCCULATION == 'Low')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 $sql .= "', flocculation='0";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 else if ($yeast->FLOCCULATION == 'Medium')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 $sql .= "', flocculation='1";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 else if ($yeast->FLOCCULATION == 'High')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 $sql .= "', flocculation='2";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 else if ($yeast->FLOCCULATION == 'Very high')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 $sql .= "', flocculation='3";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 else
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 echo "Unknown FLOCCULATION " . $yeast->FLOCCULATION . PHP_EOL;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 if ($yeast->ATTENUATION)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 $sql .= "', attenuation='" . floatval($yeast->ATTENUATION);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 $sql .= "', notes='" . mysqli_real_escape_string($db, $yeast->NOTES);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 $sql .= "', best_for='" . mysqli_real_escape_string($db, $yeast->BEST_FOR);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 if ($yeast->MAX_REUSE)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 $sql .= "', max_reuse='" . $yeast->MAX_REUSE;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 if ($yeast->FORM == 'Liquid') {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 if ($yeast->LABORATORY == 'Imperial Yeast')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 $sql .= "', cells='200000000000"; // 200 billion cells per pack
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 else
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 $sql .= "', cells='100000000000"; // 100 billion cells per pack
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 if ($yeast->COST)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 $sql .= "', cost='" . floatval($yeast->COST);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 if ($yeast->INVENTORY)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 $sql .= "', inventory='" . floatval($yeast->INVENTORY);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 } else if ($yeast->FORM == 'Dry') {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 $sql .= "', cells='15000000000"; // 6..15 billion per gram
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 if ($yeast->INVENTORY)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 $sql .= "', inventory='" . floatval($yeast->INVENTORY) / 1000.0; // To kg
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 if ($yeast->COST)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 $sql .= "', cost='" . floatval($yeast->COST) * 1000.0; // to Euro/kg
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 } else {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 $sql .= "', cells='1700000000"; // 1.7 billion cells per ml.
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 if ($yeast->INVENTORY)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 $sql .= "', inventory='" . floatval($yeast->INVENTORY) / 1000.0; // To liter
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 if ($yeast->COST)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 $sql .= "', cost='" . floatval($yeast->COST) * 1000.0; // to Euro/liter
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 if ($yeast->CULTURE_DATE) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 $date = substr($yeast->CULTURE_DATE, 6, 4) . '-' . substr($yeast->CULTURE_DATE, 3, 2) . '-' . substr($yeast->CULTURE_DATE, 0, 2);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 $sql .= "', production_date='" . $date;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 $sql .= "';";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 if (! $result = mysqli_query($db, $sql)) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 echo "Fout 8: " . mysqli_error($db) . "<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 } else {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 echo "+ " . $yeast->NAME . "<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 $imported++;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 if ($imported == 0) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 echo "Fout 7: geen gisten in dit bestand.<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 } else {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 echo $imported . " gisten toegevoegd.<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 // Don't clutter the upload directory.
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 unlink($target_file);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 ?>

mercurial