dodanie csrf, oauth 2, dockerfile

This commit is contained in:
Marcin Cieślikowski
2026-03-16 10:43:19 +01:00
parent 56c7ecff6d
commit 9023b9a5ed
26 changed files with 872 additions and 274 deletions
+20 -17
View File
@@ -5,18 +5,20 @@ checkAuth();
$message = '';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$product_name = trim($_POST['product_name']);
$quantity = (int)$_POST['quantity'];
$purchase_place = trim($_POST['purchase_place']);
$price = (float)str_replace(',', '.', $_POST['price_per_unit']);
$delivery_date = $_POST['delivery_date'];
$notes = trim($_POST['notes']);
$recipient = trim($_POST['recipient']);
$delivery_address = trim($_POST['delivery_address']);
$company = trim($_POST['company'] ?? ''); // NOWE POLE
if ($_SERVER["REQUEST_METHOD"] === "POST") {
requireCsrfToken();
if (!empty($product_name) && $quantity > 0) {
$product_name = trim($_POST['product_name'] ?? '');
$quantity = (int)($_POST['quantity'] ?? 0);
$purchase_place = trim($_POST['purchase_place'] ?? '');
$price = (float)str_replace(',', '.', $_POST['price_per_unit'] ?? '0');
$delivery_date = $_POST['delivery_date'] ?? '';
$notes = trim($_POST['notes'] ?? '');
$recipient = trim($_POST['recipient'] ?? '');
$delivery_address = trim($_POST['delivery_address'] ?? '');
$company = trim($_POST['company'] ?? '');
if ($product_name !== '' && $quantity > 0) {
try {
$pdo->beginTransaction();
@@ -33,11 +35,11 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$hist_stmt->execute([$order_id, $_SESSION['user_id'], 'Utworzono nowe zamówienie.']);
$pdo->commit();
$message = "<div class='alert alert-success'>Zamówienie dodane pomyślnie!</div>";
$message = "<div class='alert alert-success'>Zamówienie dodane pomyślnie.</div>";
} catch (PDOException $e) {
$pdo->rollBack();
$message = "<div class='alert alert-danger'>Błąd: " . $e->getMessage() . "</div>";
error_log($e->getMessage());
$message = "<div class='alert alert-danger'>Nie udało się zapisać zamówienia.</div>";
}
} else {
$message = "<div class='alert alert-warning'>Wypełnij nazwę produktu i ilość.</div>";
@@ -49,7 +51,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
<html lang="pl">
<head>
<meta charset="UTF-8">
<title>Dodaj zamówienie - <?php echo APP_NAME; ?></title>
<title>Dodaj zamówienie - <?php echo e(APP_NAME); ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
</head>
@@ -62,6 +64,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
<div class="card-body">
<?php echo $message; ?>
<form method="POST">
<?php echo csrfInput(); ?>
<div class="mb-3 p-2 bg-success bg-opacity-10 border border-success rounded">
<label class="form-label small fw-bold text-success"><i class="bi bi-building"></i> Firma kupująca</label>
@@ -90,13 +93,13 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
</div>
</div>
<div class="mb-3">
<label class="form-label small fw-bold">Sklep / Miejsce zakupu</label>
<label class="form-label small fw-bold">Sklep / miejsce zakupu</label>
<input type="text" name="purchase_place" class="form-control">
</div>
<div class="row bg-light p-3 border rounded mb-3">
<div class="col-md-6 mb-3 mb-md-0">
<label class="form-label small fw-bold text-primary">Odbiorca / Projekt</label>
<label class="form-label small fw-bold text-primary">Odbiorca / projekt</label>
<input type="text" name="recipient" class="form-control form-control-sm">
</div>
<div class="col-md-6">