码桶
发现社区成员的开源项目
request.php3.6 KB
<?php
/**
* 求软件
*
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$submitMsg = '';
$submitOk = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$reqName = trim($_POST['name'] ?? '');
$reqContent = trim($_POST['content'] ?? '');
$reqContact = trim($_POST['contact'] ?? '');
if ($reqName === '' || $reqContent === '') {
$submitMsg = '请填写软件名称和详细描述';
} else {
$subject = '【求软件】' . $reqName;
$mailBody = '<h3>收到新的求软件请求</h3>'
. '<p><b>软件名称:</b>' . htmlspecialchars($reqName) . '</p>'
. '<p><b>详细描述:</b><br>' . nl2br(htmlspecialchars($reqContent)) . '</p>'
. ($reqContact !== '' ? '<p><b>联系方式:</b>' . htmlspecialchars($reqContact) . '</p>' : '')
. '<p><b>提交时间:</b>' . date('Y-m-d H:i') . '</p>';
$feishuText = '【求软件】' . $reqName . "\n"
. '软件名称:' . $reqName . "\n"
. '详细描述:' . $reqContent . "\n"
. ($reqContact !== '' ? '联系方式:' . $reqContact . "\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="req-name">软件名称 <em>*</em></label>
<input class="submit-form-input" type="text" id="req-name" name="name" required
placeholder="请输入你想找的软件名称" value="<?php echo htmlspecialchars($reqName ?? ''); ?>">
</div>
<div class="submit-form-row">
<label class="submit-form-label" for="req-content">详细描述 <em>*</em></label>
<textarea class="submit-form-textarea" id="req-content" name="content" rows="5" required
placeholder="尽量描述软件的功能、版本、平台等,方便我们快速找到"><?php echo htmlspecialchars($reqContent ?? ''); ?></textarea>
</div>
<div class="submit-form-row">
<label class="submit-form-label" for="req-contact">联系方式</label>
<input class="submit-form-input" type="text" id="req-contact" name="contact"
placeholder="QQ / 邮箱,方便我们找到后通知你(选填)" value="<?php echo htmlspecialchars($reqContact ?? ''); ?>">
</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'); ?>