Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <?php
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- error_reporting(E_ALL);
- ob_start();
- // Servings per container
- if (isset($_GET['servingPerContainer'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountServingPerContainer = strlen($_GET['servingPerContainer']);
- if ($_GET['servingPerContainer'] && $strCountServingPerContainer != 0) {
- $servingPerContainer = $_GET['servingPerContainer'];
- $servingPerContainerBoolean = "true";
- }else{
- $servingPerContainer = 0;
- $servingPerContainerBoolean = "false";
- }
- }
- // Serving size unit
- if (isset($_GET['servingSizeUnit'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountServingSizeUnit = strlen($_GET['servingSizeUnit']);
- if ($_GET['servingSizeUnit'] && $strCountServingSizeUnit != 0) {
- $servingSizeUnit = $_GET['servingSizeUnit'];
- $servingServingSizeBoolean = true;
- }else{
- $servingSizeUnit = "null";
- $servingServingSizeBoolean = "false";
- }
- }
- // Serving size
- if (isset($_GET['servingSize'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountServingSize = strlen($_GET['servingSize']);
- if ($_GET['servingSize'] && $strCountServingSize != 0) {
- $servingSize = $_GET['servingSize'];
- $servingServingBoolean = true;
- }else{
- $servingUnit = 0;
- $servingServingBoolean = "false";
- }
- }
- //Calories
- if (isset($_GET['Calories'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountCalories = strlen($_GET['Calories']);
- if ($_GET['Calories'] && $strCountCalories != 0) {
- $calories = $_GET['Calories'];
- $caloriesBoolean = true;
- }else{
- $calories = "null";
- $caloriesBoolean = "false";
- }
- }
- //Total fat
- if (isset($_GET['TotalFat'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountTotalFat = strlen($_GET['TotalFat']);
- if ($_GET['TotalFat'] && $strCountTotalFat != 0) {
- $totalFat = $_GET['TotalFat'];
- $totalFatBoolean = "true";
- }else{
- $totalFat = "null";
- $totalFatBoolean = "false";
- }
- }
- //Saturated Fat
- if (isset($_GET['SaturatedFat'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountSaturatedFat = strlen($_GET['SaturatedFat']);
- if ($_GET['SaturatedFat'] && $strCountSaturatedFat != 0) {
- $saturatedFat = $_GET['SaturatedFat'];
- $saturatedFatBoolean = "true";
- }else{
- $saturatedFat = 0;
- $saturatedFatBoolean = "true";
- }
- }
- //Saturated Fat
- if (isset($_GET['TransFat'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountTransFat = strlen($_GET['TransFat']);
- if ($_GET['TransFat']) {
- $transFat = $_GET['TransFat'];
- $transFatBoolean = "true";
- }else{
- $transFat = $_GET['TransFat'];
- $transFatBoolean = "true";
- }
- }
- //Colesterol
- if (isset($_GET['Colesterol'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountColesterol = strlen($_GET['Colesterol']);
- if ($_GET['Colesterol']) {
- $colesterol = $_GET['Colesterol'];
- $colesterolBoolean = "true";
- }else{
- $colesterol = 0;
- $colesterolBoolean = "true";
- }
- }
- //Sodium
- if (isset($_GET['Sodium'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountSodium = strlen($_GET['Sodium']);
- if ($_GET['Sodium'] > 0) {
- $sodium = $_GET['Sodium'];
- $sodiumBoolean = "true";
- }else{
- $sodium = 0;
- $sodiumBoolean = "true";
- }
- }
- //Carb
- if (isset($_GET['Carb'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountCarb = strlen($_GET['Carb']);
- if ($_GET['Carb'] > 0) {
- $carb = $_GET['Carb'];
- $carbBoolean = "true";
- }else{
- $carb = 0;
- $carbBoolean = "true";
- }
- }
- //Dietary Fiber
- if (isset($_GET['DietaryFiber'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountDietaryFiber = strlen($_GET['DietaryFiber']);
- if ($_GET['DietaryFiber'] > 0) {
- $dietaryFiber = $_GET['DietaryFiber'];
- $dietaryFiberBoolean = "true";
- }else{
- $dietaryFiber = 0;
- $dietaryFiberBoolean = "true";
- }
- }
- //Sugars
- if (isset($_GET['Sugars'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountSugars = strlen($_GET['Sugars']);
- if ($_GET['Sugars'] > 0) {
- $sugars = $_GET['Sugars'];
- $sugarsBoolean = "true";
- }else{
- $sugars = 0;
- $sugarsBoolean = "true";
- }
- }
- //added Sugars
- if (isset($_GET['AddedSugars'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountAddedSugars = strlen($_GET['AddedSugars']);
- if ($_GET['AddedSugars'] > 0) {
- $addedSugars = $_GET['AddedSugars'];
- $addedSugarsBoolean = "true";
- }else{
- $addedSugars = 0;
- $addedSugarsBoolean = "true";
- }
- }
- //Protein
- if (isset($_GET['Protein'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountProtein = strlen($_GET['Protein']);
- if ($_GET['Protein'] > 0) {
- $protein = $_GET['Protein'];
- $proteinBoolean = "true";
- }else{
- $protein = 0;
- $proteinBoolean = "true";
- }
- }
- //Want Vitimins
- if (isset($_GET['WantVitamins'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountProtein = strlen($_GET['WantVitamins']);
- if (strtolower($_GET['WantVitamins']) === 'yes') {
- $wantVitamins = "true";
- }else{
- $wantVitamins = "false";
- }
- }
- //VitaminD
- if (isset($_GET['VitaminD'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountVitaminD = strlen($_GET['VitaminD']);
- if ($_GET['VitaminD'] > 0) {
- $vitaminD = $_GET['VitaminD'];
- }else{
- $vitaminD = 0;
- }
- }
- //Calcium
- if (isset($_GET['Calcium'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountCalcium = strlen($_GET['Calcium']);
- if ($_GET['Calcium'] > 0) {
- $calcium = $_GET['Calcium'];
- }else{
- $calcium = 0;
- }
- }
- //Iron
- if (isset($_GET['Iron'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountIron = strlen($_GET['Iron']);
- if ($_GET['Iron'] > 0) {
- $iron = $_GET['Iron'];
- }else{
- $iron = 0;
- }
- }
- //Potassium
- if (isset($_GET['Potassium'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountIron = strlen($_GET['Potassium']);
- if ($_GET['Potassium'] > 0) {
- $potassium= $_GET['Potassium'];
- }else{
- $potassium = 0;
- }
- }
- //ingredient List
- if (isset($_GET['IngredientList'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $strCountIngredientList = strlen($_GET['IngredientList']);
- if ($strCountIngredientList > 0) {
- $ingredientList = $_GET['IngredientList'];
- $ingredientListBoolean = "true";
- }else{
- $ingredientList = "";
- $ingredientListBoolean = "false";
- }
- }
- //ingredient List
- if (isset($_GET['ProductName'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- $productName = $_GET['ProductName'];
- }else{
- $productName = 'error product name';
- }
- //uk version
- if (isset($_GET['ukv'])) {
- // Check if paramater is provided
- // Check length to know if value isn't empty
- if (strtolower($_GET['ukv']) === 'yes') {
- $uk = "true";
- $ukv = $_GET['ukv'];
- }else{
- $uk = "false";
- $ukv = $_GET['ukv'];
- }
- }else {
- $uk = 'false';
- $ukv = $_GET['ukv'];
- }
- ?>
- <html lang="en">
- <head>
- <title>Pabel - Nutrition Label Generator</title>
- <!-- include the needed font from google api -->
- <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Archivo+Black" />
- <!-- include the nutrition label plugin css file -->
- <link rel="stylesheet" type="text/css" href="node_modules/nutrition-label-jquery-plugin/dist/css/nutritionLabel-min.css">
- <!-- include the jquery library -->
- <script
- src="https://code.jquery.com/jquery-3.4.1.min.js"
- integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
- crossorigin="anonymous"></script>
- <!-- include the nutrition label plugin js file -->
- <script type="text/javascript" src="node_modules/nutrition-label-jquery-plugin/dist/js/nutritionLabel-min.js"></script>
- </head>
- <body>
- <div id="label">
- </div>
- <script type="text/javascript">
- $('#label').nutritionLabel({
- showLegacyVersion : false,
- valueServingPerContainer : <?php echo $servingPerContainer; ?>,
- showServingsPerContainer : true,
- valueServingSizeUnit : '<?php echo $servingSizeUnit; ?>',
- valueServingUnitQuantity : <?php echo $servingSize; ?>,
- showItemName : true,
- showCalories : <?php echo $caloriesBoolean; ?>,
- valueCalories :<?php echo $calories; ?> ,
- valueTotalFat : <?php echo $totalFat; ?>,
- showTotalFat : <?php echo $totalFatBoolean; ?>,
- showSatFat : <?php echo $saturatedFatBoolean; ?>,
- valueSatFat : <?php echo $saturatedFat; ?>,
- showTransFat : <?php echo $transFatBoolean; ?>,
- valueTransFat : <?php echo $transFat; ?>,
- showCholesterol : <?php echo $colesterolBoolean; ?>,
- valueCholesterol : <?php echo $colesterol; ?>,
- showSodium : <?php echo $colesterolBoolean; ?>,
- valueSodium : <?php echo $sodium; ?>,
- valueTotalCarb : <?php echo $carb; ?>,
- valueFibers : <?php echo $dietaryFiber;?>,
- showFibers : <?php echo $dietaryFiberBoolean;?>,
- //Vitamins
- showVitaminD : <?php echo $wantVitamins;?>,
- valueVitaminD : <?php echo $vitaminD;?>,
- showPotassium_2018 : <?php echo $wantVitamins;?>,
- valuePotassium_2018 : <?php echo $potassium;?>,
- showCalcium : <?php echo $wantVitamins;?>,
- valueCalcium : <?php echo $calcium; ?>,
- showIron : <?php echo $wantVitamins;?>,
- valueIron : <?php echo $iron; ?>,
- //change later
- showCaffeine : <?php echo $wantVitamins;?>,
- valueSugars : <?php echo $sugars;?>,
- valueAddedSugars : <?php echo $addedSugars;?>,
- valueProteins : <?php echo $protein;?>,
- ingredientList : '<?php echo $ingredientList;?>',
- itemName : '<?php echo "$productName"; ?>',
- showIngredients : <?php echo $ingredientListBoolean;?>,
- showUKVersion : <?php echo $uk;?>,
- showItemNameForUK : true,
- <?php if ($uk === "true") {
- echo "valueServingWeightGrams : 77,
- dailyValueTotalFat : 70, //this should be 70 for the uk version
- dailyValueCarb : 260, //this should be 260 for the uk version
- dailyValueSugar : 90, //this should be 90 for the uk version
- textCalories : 'Energy',
- textTotalCarb : 'Carbohydrate',
- textFibers : 'Fibre',
- textSodium : 'Salt',
- showServingUnitQuantity : true,
- ingredientList : '".$ingredientList."',
- decimalPlacesForQuantityTextbox : 2,
- valueServingUnitQuantity : 1,
- allowFDARounding : true,
- decimalPlacesForNutrition : 2,
- valueCalories : ".$calories.",
- valueTotalFat : ".$totalFat.",
- valueSatFat : ".$saturatedFat.",
- valueSodium : ".$sodium.",
- valueTotalCarb : ".$carb.",
- valueFibers : ".$dietaryFiber.",
- valueSugars : ".$sugars.",
- valueProteins : ".$protein."";
- } ?>
- });
- </script>
- <?php
- $id = $_GET['id'];
- $dir = $id;
- //
- // if(is_dir("../UPLOADS/".$dir) === false ){
- // mkdir("../UPLOADS/".$dir,0777, true);
- // }
- // if(is_dir("../UPLOADS/".$dir."/NUTRITION-LABEL") === false ){
- // mkdir("../UPLOADS/".$dir."/NUTRITION-LABEL",0777, true);
- // }
- ?>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement