440 } |
440 } |
441 |
441 |
442 |
442 |
443 |
443 |
444 |
444 |
445 function do_recipes() |
445 function do_recipes($brews) |
446 { |
446 { |
447 global $brouwhulp, $db; |
447 global $brouwhulp, $db; |
448 $len_fermentables = 0; |
448 $len_fermentables = 0; |
449 $len_hops = 0; |
449 $len_hops = 0; |
450 $len_miscs = 0; |
450 $len_miscs = 0; |
451 $len_yeasts = 0; |
451 $len_yeasts = 0; |
452 $len_waters = 0; |
452 $len_waters = 0; |
453 $len_mash = 0; |
453 $len_mash = 0; |
454 |
454 |
455 echo " Start adding recipes to the database\n"; |
455 if ($brews) { |
456 $sql = "TRUNCATE TABLE recipes;"; |
456 echo " Start adding brews to the database\n"; |
|
457 $sql = "TRUNCATE TABLE production;"; |
|
458 } else { |
|
459 echo " Start adding recipes to the database\n"; |
|
460 $sql = "TRUNCATE TABLE recipes;"; |
|
461 } |
457 if (! $result = mysqli_query($db, $sql)) { |
462 if (! $result = mysqli_query($db, $sql)) { |
458 printf("Error: %s\n", mysqli_error($db)); |
463 printf("Error: %s\n", mysqli_error($db)); |
459 } |
464 } |
460 |
465 |
461 $recipes= simplexml_load_file($brouwhulp . '/recipes.xml'); |
466 if ($brews) |
|
467 $recipes = simplexml_load_file($brouwhulp . '/brews.xml'); |
|
468 else |
|
469 $recipes = simplexml_load_file($brouwhulp . '/recipes.xml'); |
462 |
470 |
463 foreach ($recipes->RECIPE as $recipe) { |
471 foreach ($recipes->RECIPE as $recipe) { |
464 $f_sugars = 0; |
472 $f_sugars = 0; |
465 $efficiency = 75; |
473 $efficiency = 75; |
466 $batch_size = 20; |
474 $batch_size = 20; |
468 $pCara = 0; |
476 $pCara = 0; |
469 $pSugar = 0; |
477 $pSugar = 0; |
470 $svg = 77; |
478 $svg = 77; |
471 $colorw = 0; |
479 $colorw = 0; |
472 |
480 |
473 $sql = "INSERT INTO recipes SET name='" . mysqli_real_escape_string($db, $recipe->NAME); |
481 if ($brews) |
|
482 $sql = "INSERT INTO production SET name='" . mysqli_real_escape_string($db, $recipe->NAME); |
|
483 else |
|
484 $sql = "INSERT INTO recipes SET name='" . mysqli_real_escape_string($db, $recipe->NAME); |
474 if ($recipe->NOTES) |
485 if ($recipe->NOTES) |
475 $sql .= "', notes='" . mysqli_real_escape_string($db, $recipe->NOTES); |
486 $sql .= "', notes='" . mysqli_real_escape_string($db, $recipe->NOTES); |
476 else |
487 else |
477 $sql .= "', notes='"; |
488 $sql .= "', notes='"; |
478 if ($recipe->TYPE) |
489 if ($recipe->TYPE) |