Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.53 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <?php
  4.  
  5. ini_set('display_errors', 1);
  6. ini_set('display_startup_errors', 1);
  7. error_reporting(E_ALL);
  8.  
  9. ob_start();
  10.  
  11. // Servings per container
  12. if (isset($_GET['servingPerContainer'])) {
  13. // Check if paramater is provided
  14. // Check length to know if value isn't empty
  15. $strCountServingPerContainer = strlen($_GET['servingPerContainer']);
  16. if ($_GET['servingPerContainer'] && $strCountServingPerContainer != 0) {
  17. $servingPerContainer = $_GET['servingPerContainer'];
  18. $servingPerContainerBoolean = "true";
  19. }else{
  20. $servingPerContainer = 0;
  21. $servingPerContainerBoolean = "false";
  22. }
  23. }
  24.  
  25. // Serving size unit
  26. if (isset($_GET['servingSizeUnit'])) {
  27. // Check if paramater is provided
  28. // Check length to know if value isn't empty
  29. $strCountServingSizeUnit = strlen($_GET['servingSizeUnit']);
  30. if ($_GET['servingSizeUnit'] && $strCountServingSizeUnit != 0) {
  31. $servingSizeUnit = $_GET['servingSizeUnit'];
  32. $servingServingSizeBoolean = true;
  33. }else{
  34. $servingSizeUnit = "null";
  35. $servingServingSizeBoolean = "false";
  36. }
  37. }
  38.  
  39. // Serving size
  40. if (isset($_GET['servingSize'])) {
  41. // Check if paramater is provided
  42. // Check length to know if value isn't empty
  43. $strCountServingSize = strlen($_GET['servingSize']);
  44. if ($_GET['servingSize'] && $strCountServingSize != 0) {
  45. $servingSize = $_GET['servingSize'];
  46. $servingServingBoolean = true;
  47. }else{
  48. $servingUnit = 0;
  49. $servingServingBoolean = "false";
  50. }
  51. }
  52.  
  53. //Calories
  54. if (isset($_GET['Calories'])) {
  55. // Check if paramater is provided
  56. // Check length to know if value isn't empty
  57. $strCountCalories = strlen($_GET['Calories']);
  58. if ($_GET['Calories'] && $strCountCalories != 0) {
  59. $calories = $_GET['Calories'];
  60. $caloriesBoolean = true;
  61. }else{
  62. $calories = "null";
  63. $caloriesBoolean = "false";
  64. }
  65. }
  66.  
  67. //Total fat
  68. if (isset($_GET['TotalFat'])) {
  69. // Check if paramater is provided
  70. // Check length to know if value isn't empty
  71. $strCountTotalFat = strlen($_GET['TotalFat']);
  72. if ($_GET['TotalFat'] && $strCountTotalFat != 0) {
  73. $totalFat = $_GET['TotalFat'];
  74. $totalFatBoolean = "true";
  75. }else{
  76. $totalFat = "null";
  77. $totalFatBoolean = "false";
  78. }
  79. }
  80.  
  81. //Saturated Fat
  82. if (isset($_GET['SaturatedFat'])) {
  83. // Check if paramater is provided
  84. // Check length to know if value isn't empty
  85. $strCountSaturatedFat = strlen($_GET['SaturatedFat']);
  86. if ($_GET['SaturatedFat'] && $strCountSaturatedFat != 0) {
  87. $saturatedFat = $_GET['SaturatedFat'];
  88. $saturatedFatBoolean = "true";
  89. }else{
  90. $saturatedFat = 0;
  91. $saturatedFatBoolean = "true";
  92. }
  93. }
  94.  
  95. //Saturated Fat
  96. if (isset($_GET['TransFat'])) {
  97. // Check if paramater is provided
  98. // Check length to know if value isn't empty
  99. $strCountTransFat = strlen($_GET['TransFat']);
  100. if ($_GET['TransFat']) {
  101. $transFat = $_GET['TransFat'];
  102. $transFatBoolean = "true";
  103. }else{
  104. $transFat = $_GET['TransFat'];
  105. $transFatBoolean = "true";
  106. }
  107. }
  108.  
  109. //Colesterol
  110. if (isset($_GET['Colesterol'])) {
  111. // Check if paramater is provided
  112. // Check length to know if value isn't empty
  113. $strCountColesterol = strlen($_GET['Colesterol']);
  114. if ($_GET['Colesterol']) {
  115. $colesterol = $_GET['Colesterol'];
  116. $colesterolBoolean = "true";
  117. }else{
  118. $colesterol = 0;
  119. $colesterolBoolean = "true";
  120. }
  121. }
  122.  
  123. //Sodium
  124. if (isset($_GET['Sodium'])) {
  125. // Check if paramater is provided
  126. // Check length to know if value isn't empty
  127. $strCountSodium = strlen($_GET['Sodium']);
  128. if ($_GET['Sodium'] > 0) {
  129. $sodium = $_GET['Sodium'];
  130. $sodiumBoolean = "true";
  131. }else{
  132. $sodium = 0;
  133. $sodiumBoolean = "true";
  134. }
  135. }
  136.  
  137. //Carb
  138. if (isset($_GET['Carb'])) {
  139. // Check if paramater is provided
  140. // Check length to know if value isn't empty
  141. $strCountCarb = strlen($_GET['Carb']);
  142. if ($_GET['Carb'] > 0) {
  143. $carb = $_GET['Carb'];
  144. $carbBoolean = "true";
  145. }else{
  146. $carb = 0;
  147. $carbBoolean = "true";
  148. }
  149. }
  150.  
  151. //Dietary Fiber
  152. if (isset($_GET['DietaryFiber'])) {
  153. // Check if paramater is provided
  154. // Check length to know if value isn't empty
  155. $strCountDietaryFiber = strlen($_GET['DietaryFiber']);
  156. if ($_GET['DietaryFiber'] > 0) {
  157. $dietaryFiber = $_GET['DietaryFiber'];
  158. $dietaryFiberBoolean = "true";
  159. }else{
  160. $dietaryFiber = 0;
  161. $dietaryFiberBoolean = "true";
  162. }
  163. }
  164.  
  165. //Sugars
  166. if (isset($_GET['Sugars'])) {
  167. // Check if paramater is provided
  168. // Check length to know if value isn't empty
  169. $strCountSugars = strlen($_GET['Sugars']);
  170. if ($_GET['Sugars'] > 0) {
  171. $sugars = $_GET['Sugars'];
  172. $sugarsBoolean = "true";
  173. }else{
  174. $sugars = 0;
  175. $sugarsBoolean = "true";
  176. }
  177. }
  178.  
  179. //added Sugars
  180. if (isset($_GET['AddedSugars'])) {
  181. // Check if paramater is provided
  182. // Check length to know if value isn't empty
  183. $strCountAddedSugars = strlen($_GET['AddedSugars']);
  184. if ($_GET['AddedSugars'] > 0) {
  185. $addedSugars = $_GET['AddedSugars'];
  186. $addedSugarsBoolean = "true";
  187. }else{
  188. $addedSugars = 0;
  189. $addedSugarsBoolean = "true";
  190. }
  191. }
  192.  
  193. //Protein
  194. if (isset($_GET['Protein'])) {
  195. // Check if paramater is provided
  196. // Check length to know if value isn't empty
  197. $strCountProtein = strlen($_GET['Protein']);
  198. if ($_GET['Protein'] > 0) {
  199. $protein = $_GET['Protein'];
  200. $proteinBoolean = "true";
  201. }else{
  202. $protein = 0;
  203. $proteinBoolean = "true";
  204. }
  205. }
  206.  
  207. //Want Vitimins
  208. if (isset($_GET['WantVitamins'])) {
  209. // Check if paramater is provided
  210. // Check length to know if value isn't empty
  211. $strCountProtein = strlen($_GET['WantVitamins']);
  212.  
  213.  
  214. if (strtolower($_GET['WantVitamins']) === 'yes') {
  215. $wantVitamins = "true";
  216. }else{
  217. $wantVitamins = "false";
  218. }
  219. }
  220.  
  221. //VitaminD
  222. if (isset($_GET['VitaminD'])) {
  223. // Check if paramater is provided
  224. // Check length to know if value isn't empty
  225. $strCountVitaminD = strlen($_GET['VitaminD']);
  226. if ($_GET['VitaminD'] > 0) {
  227. $vitaminD = $_GET['VitaminD'];
  228. }else{
  229. $vitaminD = 0;
  230. }
  231. }
  232. //Calcium
  233. if (isset($_GET['Calcium'])) {
  234. // Check if paramater is provided
  235. // Check length to know if value isn't empty
  236. $strCountCalcium = strlen($_GET['Calcium']);
  237. if ($_GET['Calcium'] > 0) {
  238. $calcium = $_GET['Calcium'];
  239. }else{
  240. $calcium = 0;
  241. }
  242. }
  243.  
  244. //Iron
  245. if (isset($_GET['Iron'])) {
  246. // Check if paramater is provided
  247. // Check length to know if value isn't empty
  248. $strCountIron = strlen($_GET['Iron']);
  249. if ($_GET['Iron'] > 0) {
  250. $iron = $_GET['Iron'];
  251. }else{
  252. $iron = 0;
  253. }
  254. }
  255.  
  256. //Potassium
  257. if (isset($_GET['Potassium'])) {
  258. // Check if paramater is provided
  259. // Check length to know if value isn't empty
  260. $strCountIron = strlen($_GET['Potassium']);
  261. if ($_GET['Potassium'] > 0) {
  262. $potassium= $_GET['Potassium'];
  263. }else{
  264. $potassium = 0;
  265. }
  266. }
  267.  
  268. //ingredient List
  269. if (isset($_GET['IngredientList'])) {
  270. // Check if paramater is provided
  271. // Check length to know if value isn't empty
  272. $strCountIngredientList = strlen($_GET['IngredientList']);
  273. if ($strCountIngredientList > 0) {
  274. $ingredientList = $_GET['IngredientList'];
  275. $ingredientListBoolean = "true";
  276. }else{
  277. $ingredientList = "";
  278. $ingredientListBoolean = "false";
  279. }
  280. }
  281.  
  282. //ingredient List
  283. if (isset($_GET['ProductName'])) {
  284. // Check if paramater is provided
  285. // Check length to know if value isn't empty
  286. $productName = $_GET['ProductName'];
  287.  
  288. }else{
  289. $productName = 'error product name';
  290. }
  291.  
  292.  
  293.  
  294. //uk version
  295. if (isset($_GET['ukv'])) {
  296. // Check if paramater is provided
  297. // Check length to know if value isn't empty
  298. if (strtolower($_GET['ukv']) === 'yes') {
  299. $uk = "true";
  300. $ukv = $_GET['ukv'];
  301. }else{
  302. $uk = "false";
  303. $ukv = $_GET['ukv'];
  304. }
  305. }else {
  306. $uk = 'false';
  307. $ukv = $_GET['ukv'];
  308. }
  309.  
  310.  
  311. ?>
  312. <html lang="en">
  313. <head>
  314. <title>Pabel - Nutrition Label Generator</title>
  315.  
  316. <!-- include the needed font from google api -->
  317. <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Archivo+Black" />
  318. <!-- include the nutrition label plugin css file -->
  319. <link rel="stylesheet" type="text/css" href="node_modules/nutrition-label-jquery-plugin/dist/css/nutritionLabel-min.css">
  320. <!-- include the jquery library -->
  321. <script
  322. src="https://code.jquery.com/jquery-3.4.1.min.js"
  323. integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
  324. crossorigin="anonymous"></script>
  325. <!-- include the nutrition label plugin js file -->
  326. <script type="text/javascript" src="node_modules/nutrition-label-jquery-plugin/dist/js/nutritionLabel-min.js"></script>
  327.  
  328. </head>
  329. <body>
  330. <div id="label">
  331.  
  332. </div>
  333.  
  334. <script type="text/javascript">
  335.  
  336.  
  337.  
  338. $('#label').nutritionLabel({
  339. showLegacyVersion : false,
  340. valueServingPerContainer : <?php echo $servingPerContainer; ?>,
  341. showServingsPerContainer : true,
  342. valueServingSizeUnit : '<?php echo $servingSizeUnit; ?>',
  343. valueServingUnitQuantity : <?php echo $servingSize; ?>,
  344. showItemName : true,
  345.  
  346.  
  347.  
  348. showCalories : <?php echo $caloriesBoolean; ?>,
  349. valueCalories :<?php echo $calories; ?> ,
  350. valueTotalFat : <?php echo $totalFat; ?>,
  351. showTotalFat : <?php echo $totalFatBoolean; ?>,
  352. showSatFat : <?php echo $saturatedFatBoolean; ?>,
  353. valueSatFat : <?php echo $saturatedFat; ?>,
  354. showTransFat : <?php echo $transFatBoolean; ?>,
  355. valueTransFat : <?php echo $transFat; ?>,
  356. showCholesterol : <?php echo $colesterolBoolean; ?>,
  357. valueCholesterol : <?php echo $colesterol; ?>,
  358. showSodium : <?php echo $colesterolBoolean; ?>,
  359. valueSodium : <?php echo $sodium; ?>,
  360. valueTotalCarb : <?php echo $carb; ?>,
  361. valueFibers : <?php echo $dietaryFiber;?>,
  362. showFibers : <?php echo $dietaryFiberBoolean;?>,
  363. //Vitamins
  364. showVitaminD : <?php echo $wantVitamins;?>,
  365. valueVitaminD : <?php echo $vitaminD;?>,
  366.  
  367. showPotassium_2018 : <?php echo $wantVitamins;?>,
  368. valuePotassium_2018 : <?php echo $potassium;?>,
  369.  
  370.  
  371. showCalcium : <?php echo $wantVitamins;?>,
  372. valueCalcium : <?php echo $calcium; ?>,
  373.  
  374.  
  375. showIron : <?php echo $wantVitamins;?>,
  376. valueIron : <?php echo $iron; ?>,
  377. //change later
  378. showCaffeine : <?php echo $wantVitamins;?>,
  379.  
  380. valueSugars : <?php echo $sugars;?>,
  381. valueAddedSugars : <?php echo $addedSugars;?>,
  382. valueProteins : <?php echo $protein;?>,
  383.  
  384. ingredientList : '<?php echo $ingredientList;?>',
  385. itemName : '<?php echo "$productName"; ?>',
  386. showIngredients : <?php echo $ingredientListBoolean;?>,
  387.  
  388.  
  389. showUKVersion : <?php echo $uk;?>,
  390. showItemNameForUK : true,
  391.  
  392.  
  393.  
  394. <?php if ($uk === "true") {
  395. echo "valueServingWeightGrams : 77,
  396.  
  397. dailyValueTotalFat : 70, //this should be 70 for the uk version
  398. dailyValueCarb : 260, //this should be 260 for the uk version
  399. dailyValueSugar : 90, //this should be 90 for the uk version
  400.  
  401. textCalories : 'Energy',
  402. textTotalCarb : 'Carbohydrate',
  403. textFibers : 'Fibre',
  404. textSodium : 'Salt',
  405.  
  406. showServingUnitQuantity : true,
  407.  
  408. ingredientList : '".$ingredientList."',
  409.  
  410. decimalPlacesForQuantityTextbox : 2,
  411. valueServingUnitQuantity : 1,
  412.  
  413. allowFDARounding : true,
  414. decimalPlacesForNutrition : 2,
  415.  
  416. valueCalories : ".$calories.",
  417. valueTotalFat : ".$totalFat.",
  418. valueSatFat : ".$saturatedFat.",
  419. valueSodium : ".$sodium.",
  420. valueTotalCarb : ".$carb.",
  421. valueFibers : ".$dietaryFiber.",
  422. valueSugars : ".$sugars.",
  423.  
  424. valueProteins : ".$protein."";
  425. } ?>
  426.  
  427.  
  428. });
  429.  
  430.  
  431.  
  432. </script>
  433.  
  434. <?php
  435. $id = $_GET['id'];
  436. $dir = $id;
  437. //
  438. // if(is_dir("../UPLOADS/".$dir) === false ){
  439. // mkdir("../UPLOADS/".$dir,0777, true);
  440. // }
  441. // if(is_dir("../UPLOADS/".$dir."/NUTRITION-LABEL") === false ){
  442. // mkdir("../UPLOADS/".$dir."/NUTRITION-LABEL",0777, true);
  443. // }
  444. ?>
  445. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement