<?php require_once "../services/PasswordService.php"; require_once "../assets/php/JsonResponse.php"; $service = new PasswordService(); $response = new JsonResponse(); if (isset($_POST) && isset($_POST['action']) && $_POST["action"] == "add") { $record = $service->Create($_POST["password"]); $html = getRow($record); $response->successful("Successfully added a new password", $record, $html); } else { if (isset($_POST) && isset($_POST['action']) && $_POST["action"] == "delete") { $record = $service->Delete($_POST['id']); $response->successful("Successfully deleted a password", $record); } else { if (isset($_POST) && isset($_POST['action']) && $_POST["action"] == "edit") { $record = $service->Update($_POST["password"]); $html = getRow($record); $response->successful("Successfully updated the password", $record, $html); } else { if (isset($_POST) && isset($_POST['id'])) { $record = $service->Get($_POST['id']); $response->successful("Successfully retrieved the password", $record); } else { $records = $service->Get(); $html = "<table style='margin-bottom: 0;' class='table table-condensed table-bordered table-hover'><thead><tr>"; $html .= "<th>Place</th>"; $html .= "<th>Username</th>"; $html .= "<th>Password</th>"; $html .= "</tr></thead><tbody>"; for ($i = 0; $i < count($records); $i++) {
}); $app->get("/thankyou/", function () use($app) { $app->render("template.php", array("view" => "thankyou.html")); }); $app->get("/thankyou2/", function () use($app) { $app->render("template.php", array("view" => "thankyou2.html")); }); $app->get("/events/pokerrun/", function () use($app) { $app->render("template.php", array("view" => "pokerrun.html")); }); $app->post("/pokerrun/", function () use($app) { $data = $_POST["data"]; $response = new JsonResponse(); $response->successful("Successfully created a new request for poker run.", $data); }); $app->post("/contact/", function () use($app) { $response = new JsonResponse(); $contact = new Contact(); $result = $contact->sendContactEmail($_POST['name'], $_POST['email'], $_POST['phone'], $_POST['message']); if (result) { $response->successful("Message successfully sent. Thank you for contacting Waterfowlers for Warriors.", $result); } else { $response->unsuccessful("Failed to send message. Please try again later.", $result); } }); $app->post('/profile/', function () use($app) { $profile = new Profile(); $profile->saveProfile($_POST); $app->render("template.php", array("view" => "thankyou2.html")); }); $app->run();
$pitems = new Plinq($itemsrev); $items1 = $pitems->Where(function ($key, $value) { return $key % 2 != 0; })->ToArray(); $items2 = $pitems->Where(function ($key, $value) { return $key % 2 == 0; })->ToArray(); foreach ($items1 as $item) { $html1 .= $app->view()->fetch("item.php", ["model" => $item]); } foreach ($items2 as $item) { $html2 .= $app->view()->fetch("item.php", ["model" => $item]); } $app->render('template.php', array('view' => "home.php", 'state' => $state, 'items1' => $html1, 'items2' => $html2)); }); $app->post('/add/', function () use($app) { $response = new JsonResponse(); $itemService = new ItemService(); $model = $itemService->insert($_POST, $_FILES["images"]); $modelWithImages = $itemService->getWithImages($model->id); $html = $app->view()->fetch("item.php", ["model" => $modelWithImages]); $response->successful("Successfully added a new post", $modelWithImages, $html); }); $app->post("/delete/", function () use($app) { $response = new JsonResponse(); $itemService = new ItemService(); $id = $_POST["id"]; $result = $itemService->delete($id); $response->successful("Successfully deleted the post", $result); }); $app->run();