dodanie csrf, oauth 2, dockerfile

This commit is contained in:
Marcin Cieślikowski
2026-03-16 10:43:19 +01:00
parent 56c7ecff6d
commit df448ea7c1
26 changed files with 916 additions and 318 deletions
+30 -27
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();
@@ -30,17 +32,17 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$hist_sql = "INSERT INTO " . DB_PREFIX . "order_history (order_id, user_id, action) VALUES (?, ?, ?)";
$hist_stmt = $pdo->prepare($hist_sql);
$hist_stmt->execute([$order_id, $_SESSION['user_id'], 'Utworzono nowe zamówienie.']);
$hist_stmt->execute([$order_id, $_SESSION['user_id'], 'Utworzono nowe zamowienie.']);
$pdo->commit();
$message = "<div class='alert alert-success'>Zamówienie dodane pomyślnie!</div>";
$message = "<div class='alert alert-success'>Zamowienie dodane pomyslnie.</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 udalo sie zapisac zamowienia.</div>";
}
} else {
$message = "<div class='alert alert-warning'>Wypełnij nazwę produktu i ilość.</div>";
$message = "<div class='alert alert-warning'>Wypelnij nazwe produktu i ilosc.</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 zamowienie - <?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>
@@ -57,18 +59,19 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
<div class="container py-5">
<div class="card shadow mx-auto" style="max-width: 600px;">
<div class="card-header bg-primary text-white">
<h5 class="mb-0"><i class="bi bi-plus-circle"></i> Nowe zamówienie</h5>
<h5 class="mb-0"><i class="bi bi-plus-circle"></i> Nowe zamowienie</h5>
</div>
<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>
<label class="form-label small fw-bold text-success"><i class="bi bi-building"></i> Firma kupujaca</label>
<select name="company" class="form-select border-success">
<option value="">Wybierz firmę...</option>
<option value="Przedsiębiorstwo">Przedsiębiorstwo</option>
<option value="Spółka">Spółka</option>
<option value="">Wybierz firme...</option>
<option value="Przedsiebiorstwo">Przedsiebiorstwo</option>
<option value="Spolka">Spolka</option>
</select>
</div>
@@ -78,14 +81,14 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label small fw-bold">Ilość *</label>
<label class="form-label small fw-bold">Ilosc *</label>
<input type="number" name="quantity" class="form-control" value="1" min="1" required>
</div>
<div class="col-md-6 mb-3">
<label class="form-label small fw-bold">Cena za sztukę</label>
<label class="form-label small fw-bold">Cena za sztuke</label>
<div class="input-group">
<input type="text" name="price_per_unit" class="form-control" placeholder="0.00">
<span class="input-group-text">zł</span>
<span class="input-group-text">zl</span>
</div>
</div>
</div>
@@ -115,8 +118,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
</div>
<div class="d-flex justify-content-between">
<a href="index.php" class="btn btn-secondary">Powrót do listy</a>
<button type="submit" class="btn btn-primary"><i class="bi bi-check-lg"></i> Zapisz zamówienie</button>
<a href="index.php" class="btn btn-secondary">Powrot do listy</a>
<button type="submit" class="btn btn-primary"><i class="bi bi-check-lg"></i> Zapisz zamowienie</button>
</div>
</form>
</div>