Пример #1
0
<?php

// Page Logic
$recipe = null;
$id = Site::GetArgumentSafely('id');
if (Value::SetAndNotNull($id)) {
    $recipe = Recipe::Load($id);
    if (Value::SetAndNotNull($recipe)) {
        $recipe->LoadSteps();
        $edit = false;
        //Value::SetAndEqualTo($recipe->GetUsertrue, $GLOBALS, 'EDIT', true);
        if (Value::SetAndNotNull($_POST, 'CommentInput') && Site::CheckSecurityToken()) {
            $message = Site::GetPostValueSafely('CommentInput');
            $commentid = Site::GetPostValueSafely('CommentSelect');
            if (!is_numeric($commentid)) {
                $commentid = EMPTYSTRING;
            }
            Comment::Insert($message, $id, $commentid);
            Site::Redirect(EMPTYSTRING);
        }
    } else {
        Site::BackToHome();
    }
} else {
    Site::BackToHome();
}
// Page Output
include_once 'Pages/OnAllPages.php';
$recipebox = new RTK_Box('recipebox');
$recipedescription = new RTK_Box(null, 'recipedescription');
$recipedescription->AddChild(new RTK_Header($recipe->GetTitle()));
Пример #2
0
<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
header('Content-Type: text/html; charset=utf-8');
require_once 'config.php';
require_once 'recipe.lib.php';
require_once 'ingredient.lib.php';
// Connect to MySQL with PDO
$pdo = new PDO("mysql:host=" . $hostname . ";dbname=" . $schema, $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (isset($_GET['recipes'])) {
    $recipes = Recipe::GetRecipes($pdo);
    echo json_encode($recipes);
} else {
    if (isset($_GET['recipe'])) {
        $recipe = new Recipe($pdo);
        $recipe->Load($_GET['recipe']);
        echo json_encode($recipe);
    } else {
        if (isset($_GET['ingredients'])) {
            $ingredients = Ingredient::GetIngredients($pdo);
            echo json_encode($ingredients);
        }
    }
}