码桶

发现社区成员的开源项目

飞扬 / LB_Down 公开
main
LB_Down/report.php
report.php3.7 KB
<?php
/**
 * 内容举报
 *
 * @package custom
 */

if (!defined('__TYPECHO_ROOT_DIR__')) exit;

$submitMsg = '';
$submitOk = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $repUrl = trim($_POST['url'] ?? '');
    $repReason = trim($_POST['reason'] ?? '');
    $repContact = trim($_POST['contact'] ?? '');
    if ($repUrl === '' || $repReason === '') {
        $submitMsg = '请填写内容链接和举报原因';
    } else {
        $subject = '【内容举报】' . $repUrl;
        $mailBody = '<h3>收到新的内容举报</h3>'
                  . '<p><b>被举报链接:</b><a href="' . htmlspecialchars($repUrl) . '">' . htmlspecialchars($repUrl) . '</a></p>'
                  . '<p><b>举报原因:</b><br>' . nl2br(htmlspecialchars($repReason)) . '</p>'
                  . ($repContact !== '' ? '<p><b>联系方式:</b>' . htmlspecialchars($repContact) . '</p>' : '')
                  . '<p><b>提交时间:</b>' . date('Y-m-d H:i') . '</p>';
        $feishuText = '【内容举报】' . $repUrl . "\n"
                    . '被举报链接:' . $repUrl . "\n"
                    . '举报原因:' . $repReason . "\n"
                    . ($repContact !== '' ? '联系方式:' . $repContact . "\n" : '')
                    . '提交时间:' . date('Y-m-d H:i');
        if (lb_notify($subject, $mailBody, $feishuText)) {
            $submitOk = true;
            $submitMsg = '举报已提交,我们会尽快核实处理,感谢你的反馈!';
        } else {
            $submitMsg = '提交失败,通知服务未配置或发送失败,请稍后重试';
        }
    }
}

$this->need('header.php');
?>

<div class="content-area">
    <article class="page-content">
        <h1 class="page-title"><?php $this->title(); ?></h1>
        <div class="page-body fmt">
            <?php $this->content(); ?>
        </div>

        <div class="submit-form-wrap">
            <?php if ($submitMsg): ?>
                <div class="submit-tip <?php echo $submitOk ? 'success' : 'error'; ?>"><?php echo htmlspecialchars($submitMsg); ?></div>
            <?php endif; ?>

            <?php if (!$submitOk): ?>
            <form class="submit-form" method="post" action="">
                <div class="submit-form-row">
                    <label class="submit-form-label" for="rep-url">内容链接 <em>*</em></label>
                    <input class="submit-form-input" type="text" id="rep-url" name="url" required
                           placeholder="请粘贴要举报的内容页面链接" value="<?php echo htmlspecialchars($repUrl ?? ''); ?>">
                </div>
                <div class="submit-form-row">
                    <label class="submit-form-label" for="rep-reason">举报原因 <em>*</em></label>
                    <textarea class="submit-form-textarea" id="rep-reason" name="reason" rows="5" required
                              placeholder="如:链接失效 / 内容违规 / 侵权 / 恶意软件 等,请简要说明"><?php echo htmlspecialchars($repReason ?? ''); ?></textarea>
                </div>
                <div class="submit-form-row">
                    <label class="submit-form-label" for="rep-contact">联系方式</label>
                    <input class="submit-form-input" type="text" id="rep-contact" name="contact"
                           placeholder="QQ / 邮箱,便于核实后反馈(选填)" value="<?php echo htmlspecialchars($repContact ?? ''); ?>">
                </div>
                <div class="submit-form-row">
                    <button type="submit" class="submit-form-btn">提交举报</button>
                </div>
            </form>
            <?php endif; ?>
        </div>
    </article>
</div>

<?php $this->need('footer.php'); ?>