From a3059773b766898c1e43fb5b674a85675a02b990 Mon Sep 17 00:00:00 2001 From: "Elias F." Date: Wed, 19 Nov 2025 23:13:03 +0100 Subject: [PATCH] initial commit --- index.php | 298 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 298 insertions(+) create mode 100644 index.php diff --git a/index.php b/index.php new file mode 100644 index 0000000..ba3158d --- /dev/null +++ b/index.php @@ -0,0 +1,298 @@ + floatval(isset($_POST['sitting']) ? $_POST['sitting'] : 0), + 'office' => floatval(isset($_POST['office']) ? $_POST['office'] : 0), + 'standing' => floatval(isset($_POST['standing']) ? $_POST['standing'] : 0), + 'light_ex' => floatval(isset($_POST['light_ex']) ? $_POST['light_ex'] : 0), + 'moderate_ex' => floatval(isset($_POST['moderate_ex']) ? $_POST['moderate_ex'] : 0), + 'vigorous_ex' => floatval(isset($_POST['vigorous_ex']) ? $_POST['vigorous_ex'] : 0), + ]; + + if (!in_array($gender, ['male', 'female'])) { + $errors[] = 'Please select gender.'; + } + if ($age <= 0) { + $errors[] = 'Please enter a valid age.'; + } + if ($weight <= 0) { + $errors[] = 'Please enter a valid weight.'; + } + if ($height <= 0) { + $errors[] = 'Please enter a valid height.'; + } + + $sumHours = array_sum($hours); + if ($sumHours > 24) { + $errors[] = 'Sum of entered hours exceeds 24.'; + } + + if (empty($errors)) { + $pal = [ + 'sitting' => 1.2, + 'office' => 1.45, + 'standing' => 1.85, + 'light_ex' => 2.0, + 'moderate_ex' => 3.0, + 'vigorous_ex' => 4.0, + 'sleep' => 0.95 + ]; + + $sleepHours = max(0, 24 - $sumHours); + $weighted = 0.0; + foreach ($hours as $k => $h) { + $weighted += $h * $pal[$k]; + } + $weighted += $sleepHours * $pal['sleep']; + $avgPal = $weighted / 24.0; + + $bmr = calc_bmr($gender, $age, $weight, $height); + $dailyCalories = $bmr * $avgPal; + + $result = [ + 'bmr' => $bmr, + 'avgPal' => $avgPal, + 'dailyCalories' => $dailyCalories, + 'dailyCalories_loss_400' => max(0, $dailyCalories - 400), + 'sleepHours' => $sleepHours + ]; + } +} +?> + + + + + + Kalorienrechner + + + +

Kalorienrechner

+ + +
+ +
+ + +
+ + + + + + + + +

Enter hours spent per activity (total can be <= 24; remaining = sleep)

+ + + + + + + + + + + + + + +
+ + +
+

Results

+

BMR: kcal/day

+

Average PAL:

+

Sleep hours (calculated): h

+

Daily calories to maintain weight: kcal

+

To lose weight: about kcal (≈ -400 kcal)

+
+ + + \ No newline at end of file