86 行
4.7 KiB
PHP
86 行
4.7 KiB
PHP
<?php
|
||
require __DIR__ . '/includes/init.php';
|
||
requireLogin('realname.php');
|
||
$pageTitle = '实名认证';
|
||
$user = currentUser();
|
||
$edit = isset($_GET['edit']) && $_GET['edit'] === '1';
|
||
$msg = '';
|
||
$msgOk = false;
|
||
$errors = [];
|
||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||
verifyCsrf();
|
||
$name = trim($_POST['real_name'] ?? '');
|
||
$idno = strtoupper(trim($_POST['idno'] ?? ''));
|
||
if ($name === '' || $idno === '') {
|
||
$msg = '请填写姓名与身份证号';
|
||
} else {
|
||
$res = verifyRealNameTwoFactor($name, $idno);
|
||
if (!$res['ok']) {
|
||
$msg = $res['error'];
|
||
} else {
|
||
$ok = submitRealname($user['id'], $name, $idno);
|
||
if ($ok) {
|
||
$msg = '实名信息已提交并通过校验(已加密保管)。';
|
||
$msgOk = true;
|
||
} else {
|
||
$msg = '您已使用过一次实名修改机会,无法再次修改。如需变更,请联系管理员。';
|
||
}
|
||
}
|
||
}
|
||
}
|
||
$realname = getUserRealname($user['id']);
|
||
$verified = $realname !== null && (int) $realname['status'] === 1;
|
||
$modifyUsed = $realname !== null && (int) ($realname['modify_times'] ?? 0) >= 1;
|
||
require 'includes/header.php';
|
||
?>
|
||
<section class="section">
|
||
<div class="realname-wrap">
|
||
<h2 class="sec-title"><i class="fas fa-id-card"></i> 实名认证</h2>
|
||
<?php if ($msg): ?>
|
||
<p class="<?= $msgOk ? 'banner-ok' : 'form-err' ?>"><?= h($msg) ?></p>
|
||
<?php endif; ?>
|
||
<?php if ($verified && !$edit): ?>
|
||
<div class="panel ok-panel">
|
||
<p class="ok-line"><i class="fas fa-circle-check"></i> 你已完成实名认证。</p>
|
||
<p class="muted" style="font-size:.9rem">
|
||
姓名:<?= h(maskName(rnDecrypt($realname['real_name_enc']))) ?> |
|
||
身份证号:<?= h(maskIdno(rnDecrypt($realname['idno_enc']))) ?>
|
||
</p>
|
||
<p class="muted" style="font-size:.82rem;margin-top:6px">依据《个人信息保护法》,您的实名信息已加密存储,仅用于需实名商品的资格核验,不会用于其他用途。</p>
|
||
<div class="form-actions" style="margin-top:14px">
|
||
<?php if (!$modifyUsed): ?>
|
||
<a href="realname.php?edit=1" class="btn btn-ghost"><i class="fas fa-pen"></i> 修改实名信息</a>
|
||
<?php else: ?>
|
||
<p class="muted" style="font-size:.82rem">您已使用过一次实名修改机会,如需再次变更请联系管理员。</p>
|
||
<?php endif; ?>
|
||
<a href="settings.php?tab=realname" class="btn btn-ghost">返回设置</a>
|
||
</div>
|
||
</div>
|
||
<?php else: ?>
|
||
<div class="panel">
|
||
<h3><i class="fas fa-shield-alt"></i> <?= $verified ? '修改实名信息' : '提交实名信息' ?></h3>
|
||
<p class="muted" style="font-size:.88rem;margin-bottom:14px;line-height:1.7">
|
||
部分商品(标注「需实名」)购买前须完成实名认证。依据《中华人民共和国个人信息保护法》及相关法律法规,
|
||
本站对您提供的姓名与身份证号履行以下义务:<strong>(一)仅用于实名资格核验,不超出必要范围收集或使用;
|
||
(二)采用加密技术存储,严格限制访问权限,确保信息安全;(三)未经您本人同意,不会向任何第三方披露、
|
||
共享或转让。如遇法定机关依法调取,本站将配合提供。</strong>
|
||
</p>
|
||
<form method="post" action="" class="grid-form" style="max-width:460px">
|
||
<?= csrfField() ?>
|
||
<label class="span2">真实姓名<input type="text" name="real_name" autocomplete="name" placeholder="与身份证一致" required></label>
|
||
<label class="span2">身份证号<input type="text" name="idno" autocomplete="off" placeholder="18 位居民身份证号" maxlength="18" required></label>
|
||
<div class="form-actions span2">
|
||
<button type="submit" class="btn btn-primary"><i class="fas fa-check"></i> <?= $verified ? '保存修改' : '提交并认证' ?></button>
|
||
<?php if ($verified): ?>
|
||
<a href="realname.php" class="btn btn-ghost">取消</a>
|
||
<?php else: ?>
|
||
<a href="settings.php?tab=realname" class="btn btn-ghost">返回设置</a>
|
||
<?php endif; ?>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
</section>
|
||
<?php require 'includes/footer.php'; ?>
|