403Webshell
Server IP : 202.61.199.114  /  Your IP : 216.73.217.139
Web Server : nginx/1.22.1
System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64
User : web20 ( 1018)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/c.pacim.de/web/app/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/c.pacim.de/web/app/Controllers/ApiController.php
<?php

declare(strict_types=1);

namespace App\Controllers;

use App\Models\Booking;
use App\Models\Cruise;
use App\Models\Customer;
use App\Models\Invoice;
<<<<<<< HEAD
use App\Models\User;
=======
>>>>>>> origin/main

final class ApiController extends Controller
{
    private Booking $booking;
    private Customer $customer;
    private Cruise $cruise;
    private Invoice $invoice;
<<<<<<< HEAD
    private User $user;
=======
>>>>>>> origin/main

    public function __construct()
    {
        $this->booking = new Booking();
        $this->customer = new Customer();
        $this->cruise = new Cruise();
        $this->invoice = new Invoice();
<<<<<<< HEAD
        $this->user = new User();
=======
>>>>>>> origin/main
    }

    public function bookingsSearch(): never
    {
        $filters = [
            'q' => trim((string) ($_GET['q'] ?? '')),
            'date' => trim((string) ($_GET['date'] ?? '')),
            'status' => trim((string) ($_GET['status'] ?? '')),
            'parking_type' => trim((string) ($_GET['parking_type'] ?? '')),
            'ship_id' => trim((string) ($_GET['ship_id'] ?? '')),
        ];
        $page = max((int) ($_GET['page'] ?? 1), 1);

        $result = $this->booking->search($filters, $page, 20);
        jsonResponse(true, 'Buchungen geladen', $result);
    }

    public function checkinSearch(): never
    {
        $q = trim((string) ($_GET['q'] ?? ''));
        $result = $this->booking->search(['q' => $q], 1, 20);
        jsonResponse(true, 'Checkin-Suchergebnis', $result);
    }

    public function bookingsUpdate(): never
    {
        $payload = $this->input();
        if (!validate_csrf($payload)) {
            jsonResponse(false, 'CSRF Token ungültig', [], 419);
        }

        $id = (int) ($payload['id'] ?? 0);
        if ($id < 1) {
            jsonResponse(false, 'Ungültige Buchung', [], 422);
        }

        $ok = $this->booking->update($id, $payload);
        jsonResponse($ok, $ok ? 'Buchung aktualisiert' : 'Keine Änderungen', ['id' => $id]);
    }

    public function bookingsCheckin(): never
    {
        $payload = $this->input();
        if (!validate_csrf($payload)) {
            jsonResponse(false, 'CSRF Token ungültig', [], 419);
        }

        $id = (int) ($payload['id'] ?? 0);
        $ok = $id > 0 && $this->booking->checkin($id);
        jsonResponse($ok, $ok ? 'Checkin erfolgreich' : 'Checkin fehlgeschlagen', ['id' => $id], $ok ? 200 : 422);
    }

    public function bookingsCheckout(): never
    {
        $payload = $this->input();
        if (!validate_csrf($payload)) {
            jsonResponse(false, 'CSRF Token ungültig', [], 419);
        }

        $id = (int) ($payload['id'] ?? 0);
        $ok = $id > 0 && $this->booking->checkout($id);
        jsonResponse($ok, $ok ? 'Checkout erfolgreich' : 'Checkout fehlgeschlagen', ['id' => $id], $ok ? 200 : 422);
    }

    public function bookingsStatus(): never
    {
        $payload = $this->input();
        if (!validate_csrf($payload)) {
            jsonResponse(false, 'CSRF Token ungültig', [], 419);
        }

        $id = (int) ($payload['id'] ?? 0);
        $status = trim((string) ($payload['status'] ?? ''));
        $allowed = ['reserved', 'checked_in', 'checked_out', 'cancelled', 'open'];

        if (!in_array($status, $allowed, true)) {
            jsonResponse(false, 'Ungültiger Status', [], 422);
        }

        $ok = $this->booking->setStatus($id, $status);
        jsonResponse($ok, $ok ? 'Status aktualisiert' : 'Status konnte nicht aktualisiert werden', ['id' => $id, 'status' => $status], $ok ? 200 : 422);
    }

    public function bookingsNote(): never
    {
        $payload = $this->input();
        if (!validate_csrf($payload)) {
            jsonResponse(false, 'CSRF Token ungültig', [], 419);
        }

        $id = (int) ($payload['id'] ?? 0);
        $note = trim((string) ($payload['note'] ?? ''));
        $ok = $this->booking->addNote($id, $note);
        jsonResponse($ok, $ok ? 'Notiz gespeichert' : 'Notiz konnte nicht gespeichert werden', ['id' => $id], $ok ? 200 : 422);
    }

    public function customersSearch(): never
    {
        $q = trim((string) ($_GET['q'] ?? ''));
        $rows = $this->customer->search($q, 1, 40);
        jsonResponse(true, 'Kunden geladen', ['rows' => $rows]);
    }

    public function cruisesList(): never
    {
        $rows = $this->cruise->list();
        jsonResponse(true, 'Kreuzfahrten geladen', ['rows' => $rows]);
    }

    public function invoicesStatus(): never
    {
        $payload = $this->input();
        if (!validate_csrf($payload)) {
            jsonResponse(false, 'CSRF Token ungültig', [], 419);
        }

        $id = (int) ($payload['id'] ?? 0);
        $status = trim((string) ($payload['status'] ?? 'open'));
        $ok = $this->invoice->setStatus($id, $status);
        jsonResponse($ok, $ok ? 'Rechnungsstatus aktualisiert' : 'Fehler beim Statuswechsel', ['id' => $id], $ok ? 200 : 422);
    }

    public function paymentsCreate(): never
    {
        $payload = $this->input();
        if (!validate_csrf($payload)) {
            jsonResponse(false, 'CSRF Token ungültig', [], 419);
        }

        $invoiceId = (int) ($payload['invoice_id'] ?? 0);
        $amount = (float) ($payload['amount'] ?? 0);
        $method = trim((string) ($payload['payment_method'] ?? 'cash'));

        if ($invoiceId < 1 || $amount <= 0) {
            jsonResponse(false, 'Ungültige Zahlungsdaten', [], 422);
        }

        $ok = $this->invoice->addPayment($invoiceId, $amount, $method);
        jsonResponse($ok, $ok ? 'Zahlung erfasst' : 'Zahlung konnte nicht erfasst werden', ['invoice_id' => $invoiceId], $ok ? 200 : 422);
    }
<<<<<<< HEAD

    public function usersSave(): never
    {
        $payload = $this->input();
        if (!validate_csrf($payload)) {
            jsonResponse(false, 'CSRF Token ungültig', [], 419);
        }

        $name = trim((string) ($payload['name'] ?? ''));
        $email = trim((string) ($payload['email'] ?? ''));
        $role = trim((string) ($payload['role'] ?? 'staff'));

        if ($name === '' || $email === '') {
            jsonResponse(false, 'Name und E-Mail sind Pflichtfelder', [], 422);
        }
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            jsonResponse(false, 'Ungültige E-Mail-Adresse', [], 422);
        }

        $ok = $this->user->save($payload);
        jsonResponse($ok, $ok ? 'Benutzer gespeichert' : 'Benutzer konnte nicht gespeichert werden', []);
    }
=======
>>>>>>> origin/main
}

Youez - 2016 - github.com/yon3zu
LinuXploit