135 lines
5.8 KiB
PHP
135 lines
5.8 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/app.php';
|
|
|
|
ensure_kyc_table();
|
|
|
|
$errors = [];
|
|
$successId = null;
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$fullName = trim((string)($_POST['full_name'] ?? ''));
|
|
$email = trim((string)($_POST['email'] ?? ''));
|
|
$phone = trim((string)($_POST['phone'] ?? ''));
|
|
$idNumber = trim((string)($_POST['id_number'] ?? ''));
|
|
$address = trim((string)($_POST['address'] ?? ''));
|
|
$docUrl = trim((string)($_POST['doc_url'] ?? ''));
|
|
|
|
if ($fullName === '' || $email === '' || $phone === '' || $idNumber === '' || $address === '' || $docUrl === '') {
|
|
$errors[] = t('alert_error');
|
|
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
$errors[] = t('alert_email');
|
|
}
|
|
|
|
if (!$errors) {
|
|
$stmt = db()->prepare(
|
|
'INSERT INTO kyc_applications (full_name, email, phone, id_number, address, doc_url, status)
|
|
VALUES (:full_name, :email, :phone, :id_number, :address, :doc_url, :status)'
|
|
);
|
|
$stmt->execute([
|
|
':full_name' => $fullName,
|
|
':email' => $email,
|
|
':phone' => $phone,
|
|
':id_number' => $idNumber,
|
|
':address' => $address,
|
|
':doc_url' => $docUrl,
|
|
':status' => 'pending',
|
|
]);
|
|
$successId = (int)db()->lastInsertId();
|
|
}
|
|
}
|
|
|
|
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
|
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
|
?>
|
|
<!doctype html>
|
|
<html lang="<?= h($lang) ?>">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title><?= h(t('kyc_title')) ?> · <?= h(t('site_name')) ?></title>
|
|
<?php if ($projectDescription): ?>
|
|
<meta name="description" content="<?= h($projectDescription) ?>" />
|
|
<meta property="og:description" content="<?= h($projectDescription) ?>" />
|
|
<meta property="twitter:description" content="<?= h($projectDescription) ?>" />
|
|
<?php endif; ?>
|
|
<?php if ($projectImageUrl): ?>
|
|
<meta property="og:image" content="<?= h($projectImageUrl) ?>" />
|
|
<meta property="twitter:image" content="<?= h($projectImageUrl) ?>" />
|
|
<?php endif; ?>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?= h((string) time()) ?>">
|
|
</head>
|
|
<body>
|
|
<nav class="navbar navbar-expand-lg navbar-light">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="<?= h(url_with_lang('index.php')) ?>"><?= h(t('site_name')) ?></a>
|
|
<div class="ms-auto lang-toggle btn-group" role="group">
|
|
<a class="btn btn-sm <?= $lang === 'zh' ? 'active' : '' ?>" href="<?= h(url_with_lang('kyc.php', ['lang' => 'zh'])) ?>">中文</a>
|
|
<a class="btn btn-sm <?= $lang === 'en' ? 'active' : '' ?>" href="<?= h(url_with_lang('kyc.php', ['lang' => 'en'])) ?>">EN</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="container my-5">
|
|
<div class="section-card">
|
|
<h1 class="section-title mb-1"><?= h(t('kyc_title')) ?></h1>
|
|
<p class="text-muted mb-4"><?= h(t('kyc_subtitle')) ?></p>
|
|
|
|
<?php if ($successId): ?>
|
|
<div class="alert alert-success d-flex justify-content-between align-items-center flex-wrap gap-2">
|
|
<div>
|
|
<strong><?= h(t('alert_success')) ?></strong>
|
|
<div class="mt-1">ID: <span class="fw-semibold"><?= h((string) $successId) ?></span></div>
|
|
</div>
|
|
<div class="d-flex gap-2">
|
|
<a class="ghost-btn text-decoration-none" href="<?= h(url_with_lang('kyc_status.php', ['id' => $successId])) ?>"><?= h(t('cta_status')) ?></a>
|
|
<button class="cta-btn" data-copy="<?= h((string) $successId) ?>" data-default="Copy ID" data-copied="Copied">Copy ID</button>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($errors): ?>
|
|
<div class="alert alert-danger">
|
|
<?= h(implode(' ', $errors)) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form method="post" class="row g-3">
|
|
<div class="col-md-6">
|
|
<label class="form-label"><?= h(t('form_name')) ?></label>
|
|
<input type="text" name="full_name" class="form-control" required value="<?= h($_POST['full_name'] ?? '') ?>">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label"><?= h(t('form_email')) ?></label>
|
|
<input type="email" name="email" class="form-control" required value="<?= h($_POST['email'] ?? '') ?>">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label"><?= h(t('form_phone')) ?></label>
|
|
<input type="text" name="phone" class="form-control" required value="<?= h($_POST['phone'] ?? '') ?>">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label"><?= h(t('form_id')) ?></label>
|
|
<input type="text" name="id_number" class="form-control" required value="<?= h($_POST['id_number'] ?? '') ?>">
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="form-label"><?= h(t('form_address')) ?></label>
|
|
<input type="text" name="address" class="form-control" required value="<?= h($_POST['address'] ?? '') ?>">
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="form-label"><?= h(t('form_doc')) ?></label>
|
|
<input type="url" name="doc_url" class="form-control" required value="<?= h($_POST['doc_url'] ?? '') ?>">
|
|
</div>
|
|
<div class="col-12 d-flex flex-wrap justify-content-between align-items-center">
|
|
<small class="text-muted"><?= h(t('form_note')) ?></small>
|
|
<button type="submit" class="cta-btn"><?= h(t('form_submit')) ?></button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</main>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/js/main.js?v=<?= h((string) time()) ?>"></script>
|
|
</body>
|
|
</html>
|