16235369cb
Highlights include configurable menus, specials, cart/checkout, taxes, customer accounts with email 2FA, newsletters, analytics, refunds, PDF/CSV exports, Square/Mailgun adapters, and optional MySQL migration. See README.md for setup and production configuration. Verified PHP/JavaScript syntax, responsive layouts, registration, 2FA, checkout, dashboard workflows, settings persistence, and PDF generation. Real Square, Mailgun, and MySQL connections require credentials/server access. Square implementation follows the official Payments API and Refunds API.
57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use FatBottom\Core\Security;
|
|
|
|
function e(mixed $value): string
|
|
{
|
|
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
|
|
}
|
|
|
|
function money(int|string|null $cents): string
|
|
{
|
|
return '$' . number_format(((int) $cents) / 100, 2);
|
|
}
|
|
|
|
function csrf_field(): string
|
|
{
|
|
return '<input type="hidden" name="_token" value="' . e(Security::csrfToken()) . '">';
|
|
}
|
|
|
|
function active_path(string $path): string
|
|
{
|
|
$current = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH);
|
|
return $current === $path ? 'is-active' : '';
|
|
}
|
|
|
|
function selected(mixed $value, mixed $expected): string
|
|
{
|
|
return (string) $value === (string) $expected ? 'selected' : '';
|
|
}
|
|
|
|
function checked(mixed $value): string
|
|
{
|
|
return (bool) $value ? 'checked' : '';
|
|
}
|
|
|
|
function store_datetime(?string $value, string $format = 'M j, Y g:i A'): string
|
|
{
|
|
if ($value === null || $value === '') {
|
|
return '';
|
|
}
|
|
|
|
$date = new DateTimeImmutable($value, new DateTimeZone('UTC'));
|
|
return $date->setTimezone(new DateTimeZone(date_default_timezone_get()))->format($format);
|
|
}
|
|
|
|
function utc_datetime(?string $value): ?string
|
|
{
|
|
if ($value === null || trim($value) === '') {
|
|
return null;
|
|
}
|
|
|
|
$date = new DateTimeImmutable($value, new DateTimeZone(date_default_timezone_get()));
|
|
return $date->setTimezone(new DateTimeZone('UTC'))->format('Y-m-d H:i:s');
|
|
}
|