<section class="index"> <?php $preptime = minutesToNextApp($userID); if ($preptime > 20 && $preptime < 100) { echo '<p class="center">You got <strong>' . $preptime . ' minutes </strong> to cook, eat & get to your next appointment. Here are some recipes:</p>'; getRecipes($preptime); } else { if ($preptime > 100) { echo '<p class="center">You got plenty of time to cook & eat.<br/> Here are some recipes:</p>'; getRecipes($preptime); } else { echo '<p class="center">It seems that you only got <strong>' . $preptime . ' minutes </strong> to cook & eat.<br/> Maybe you want to order something online?</p>'; getDeliveries(); } } ?> </section>
$out = $_GET['action'] . "`"; // switch on request name switch ($_GET['action']) { case 'addCategory': $newCat = $_GET['newCategory']; $idQ = "select max(id) from categories"; $idR = $sql->query($idQ); $idRow = $sql->fetch_array($idR); $id = $idRow[0] + 1; $insQ = $sql->prepare("insert into categories values (?, ?)"); $insR = $sql->execute($insQ, array($id, $newCat)); $out .= getCategories(); break; case 'viewRecipes': $catID = $_GET['catID']; $out .= getRecipes($catID); break; case 'addRecipe': $name = $_GET['name']; $upc = $_GET['upc']; $margin = $_GET['margin']; $servings = 0; if (!empty($_GET['servings'])) { $servings = $_GET['servings']; } $shelflife = 0; if (!empty($_GET['shelflife'])) { $shelflife = $_GET['shelflife']; } $catID = $_GET['catID']; $idQ = "select max(id) from recipes";
<?php error_reporting(E_ALL); ini_set('display_errors', 1); // Always include this file! require_once "functions.php"; // Initialize the session and check that the user accessing this page is // logged in (sessionInit() is in functions.php). sessionInit(); // Connect to the database (dbConnect() is in functions.php). $db = dbConnect(); // Get the three sets of recipes (getRecipes() is in functions.php). $breakfastList = getRecipes($db); $lunchList = getRecipes($db); $dinnerList = getRecipes($db); // The shared header file. require_once "includes/header.php"; // If a message is passed to this script in the session, display it. if (isset($_SESSION['msg']) && $_SESSION['msg'] != NULL) { echo "<p class=\"msg\">{$_SESSION['msg']}</p>"; unset($_SESSION['msg']); } ?> <div class="newmenuplan"> <h2>Add a New Menu Plan</h2> <form action="addmenuplan.php" method="post" name="addMenuPlan"> <label for="plan_name">Menu Plan Name:</label> <input type="text" name="plan_name" id="mpName"> <?php $days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
if (isset($_GET["slug"])) { require_once "oneRecipe.php"; $recipe = array(); //run getRecipe(slug) from oneRecipe.php $recipe = getRecipe($_GET["slug"]); echo json_encode($recipe, JSON_PRETTY_PRINT); /*Testdata $recipe['slug'] = $_GET["slug"]; $recipe['description'] = "Vestibulum ullamcorper dolor at consectetur sagittis. Integer suscipit quis erat nec auctor. Proin sit amet nunc sit amet elit dignissim aliquam. Nullam euismod in diam a tristique. Nulla at leo non turpis interdum bibendum eget cursus magna. Integer pulvinar suscipit eros a suscipit. Vivamus finibus commodo ligula, a vehicula sem efficitur non. Nullam neque odio, mollis sit amet faucibus in, vehicula at ipsum.";*/ //(GET) Return ALL the recipes in json } else { /* WORKAROUND THE REST REQUEST FROM ANGULAR DOESENT GET HERE, IT GOES TO RECIPES/INDEX.PHP*/ require_once "allRecipes.php"; //run getRecipes() from allRecipes.php $recipe = getRecipes(); echo json_encode($recipe, JSON_PRETTY_PRINT); } //PUT: Update a recipe } else { if ($_SERVER['REQUEST_METHOD'] == 'PUT') { $recipe = file_get_contents("php://input"); $recipe = json_decode($recipe, true); require_once "updateRecipe.php"; $recipe = putRecipe($recipe); //DROP: drop one recipe(takes slug) } else { if ($_SERVER['REQUEST_METHOD'] == 'DELETE') { //Angular and ajax calls sends json files via with: file_get_contents("php://input") //explode splits up an array, this will split it at each slash (/) so that recipe[4] contains the slug $recipe = explode("/", $_SERVER['REQUEST_URI']);