您好,欢迎来到95分类目录!站长微信:vip3632094
当前位置:95分类目录 » 站长资讯 » 35dir专区 » 文章详细 订阅RssFeed

给95分类目录后台网站审核状态加一个审核未通过的功能(附邮件通知未通过原因)

来源:本站原创 浏览:8次 时间:2025-06-09
简介:前端表单中允许管理员选择"审核不通过"状态并填写未通过原因。 后端接收未通过原因,并通过邮件发送给用户。 不保存未通过原因到数据库。

前端代码

前端表单部分保持之前建议的代码不变,确保包含"审核不通过"选项和未通过原因的输入框:

<tr>
<th>审核状态:</th>
<td><select name="web_status" id="web_status" class="sel">
    <option value="1" style="color: #333;"{#opt_selected($status, 1)#}>黑名单</option>
    <option value="2" style="color: #f30;"{#opt_selected($status, 2)#}>待审核</option>
    <option value="3" style="color: #080;"{#opt_selected($status, 3)#}>已审核</option>
    <option value="4" style="color: #f00;"{#opt_selected($status, 4)#}>审核不通过</option>
</select>
{#if $action == 'edit' || $action == 'attr'#}
    <div id="reject_reason_div" style="display: {#if $status == 4#}block{#else#}none{#/if#}; margin-top: 10px;">
        <label for="reject_reason">未通过原因:</label><br>
        <textarea name="reject_reason" id="reject_reason" cols="50" rows="3" class="ipt">{#$reject_reason#}</textarea>
    </div>
{#/if#}
</td>
</tr>

以及控制显示/隐藏的 JavaScript 代码:

<script>
document.addEventListener('DOMContentLoaded', function() {
    const statusSelect = document.getElementById('web_status');
    const rejectReasonDiv = document.getElementById('reject_reason_div');
    
    if (statusSelect && rejectReasonDiv) {
        statusSelect.addEventListener('change', function() {
            if (this.value == '4') {
                rejectReasonDiv.style.display = 'block';
            } else {
                rejectReasonDiv.style.display = 'none';
            }
        });
    }
});
</script>


后端代码修改(不存储到数据库)

以下是基于您提供的 文件的具体修改位置和代码:website.php

1. 在 部分添加"审核不通过"状态显示$action == 'list'

找到 中状态显示的部分(大约在第 94 行),修改 代码如下:if ($action == 'list') { ... }switch ($web['web_status'])


switch ($web['web_status']) {
    case 1 :
        $web_status = '<font color="#333333">黑名单</font>';
        break;
    case 2 :
        $web_status = '<font color="#ff3300">待审核</font>';
        break;
    case 3 :
        $web_status = '<font color="#008800">已审核</font>';
        break;
    case 4 :
        $web_status = '<font color="#ff0000">审核不通过</font>';
        break;
}

2. 在 部分设置未通过原因的默认值$action == 'edit'

找到 部分(大约在第 136 行),添加 的默认值赋值(因为不从数据库加载,所以默认值为空):if ($action == 'edit') { ... }reject_reason


if ($action == 'edit') {
    $pagetitle = '编辑站点';
    $web_id = intval($_GET['web_id']);
    $where = "w.web_id=$web_id";
    $row = get_one_website($where);
    if (!$row) {
        msgbox('指定的内容不存在!');
    }
    $category_option = get_category_option('webdir', 0, $row['cate_id'], 0);
    $smarty->assign('category_option', $category_option);
    $smarty->assign('ispay', $row['web_ispay']);
    $smarty->assign('istop', $row['web_istop']);
    $smarty->assign('isbest', $row['web_isbest']);
    $smarty->assign('status', $row['web_status']);
    // 设置未通过原因的默认值(因为不存储在数据库中,默认为空)
    $smarty->assign('reject_reason', '');
    $smarty->assign('row', $row);
    $smarty->assign('h_action', 'saveedit');
}

3. 在 部分处理未通过原因并发送邮件$action == 'saveedit'

找到 部分(大约在第 247 行),修改代码以处理未通过原因并发送邮件,但不保存到数据库:if ($action == 'saveedit') { ... }


} elseif ($action == 'saveedit') {
    $web_id = intval($_POST['web_id']);
    $where = array('web_id' => $web_id);
    unset($web_data['web_ctime']);
    // 更新数据库(不包含 reject_reason)
    $DB->update($table, $web_data, $where);
    $DB->update($DB->table('webdata'), $stat_data, $where);
    $DB->query("UPDATE ".$DB->table('categories')." SET cate_postcount=cate_postcount+1 WHERE cate_id=$cate_id");
    update_cache('archives');
    require(APP_PATH.'include/sendmail.php');
    require(APP_PATH.'module/prelink.php');
    $websites = $DB->fetch_all("SELECT * FROM ".$DB->table('websites')." WHERE web_id=$web_id");
    if (!empty($websites)) {
        $user_id = $websites[0]['user_id'];
        $user = $DB->fetch_all("SELECT * FROM ".$DB->table('users')." WHERE user_id=$user_id");
        if (!empty($options['smtp_host']) && !empty($options['smtp_port']) && !empty($options['smtp_auth']) && !empty($options['smtp_user']) && !empty($options['smtp_pass'])) {
            $smarty->assign('site_name', $options['site_name']);
            $smarty->assign('site_url', $options['site_url']);
            $smarty->assign('web_name', $websites[0]['web_name']);
            if ($web_status == 3) {
                $site_link = get_website_url($websites[0]['web_id'], true);
                $smarty->assign('site_link', $site_link);
                $mailbody = $smarty->fetch('audit_mail.html');
                $subject = '['.$options['site_name'].'] 网站已通过审核!';
                sendmail($user[0]['user_email'], $subject, $mailbody);
            } elseif ($web_status == 4) {
                $reject_reason = addslashes(trim($_POST['reject_reason']));
                $smarty->assign('reject_reason', $reject_reason);
                $mailbody = $smarty->fetch('reject_mail.html');
                $subject = '['.$options['site_name'].'] 网站审核未通过';
                sendmail($user[0]['user_email'], $subject, $mailbody);
            }
        }
    }
    msgbox('网站修改成功!', $fileurl);
}

添加位置说明

  • 未通过原因的获取和处理代码添加在邮件发送逻辑中,具体在 的条件分支内,直接从 获取值并赋值给 Smarty 变量用于邮件模板渲染。$web_status == 4$_POST['reject_reason']
  • 不添加未通过原因到 数组中,因此不会保存到数据库。$web_data

4. 在 部分处理未通过原因并发送邮件$action == 'saveattr'

找到 部分(大约在第 296 行),修改代码以处理未通过原因并发送邮件,但不保存到数据库:if ($action == 'saveattr') { ... }


if ($action == 'saveattr') {
    $web_ids = (array) $_POST['web_id'];
    $web_ispay = intval($_POST['web_ispay']);
    $web_istop = intval($_POST['web_istop']);
    $web_isbest = intval($_POST['web_isbest']);
    $web_status = intval($_POST['web_status']);
    if (empty($web_ids)) {
        msgbox('请选择要设置的内容!');
    }
    require(APP_PATH.'include/sendmail.php');
    require(APP_PATH.'module/prelink.php');
    $websites = $DB->fetch_all("SELECT w.web_id, w.web_name, u.user_email FROM $table w LEFT JOIN ".$DB->table("users")." u ON w.user_id=u.user_id WHERE w.web_id IN (".dimplode($web_ids).")");
    $reject_reason = '';
    if ($web_status == 4) {
        $reject_reason = addslashes(trim($_POST['reject_reason']));
    }
    foreach ($websites as $row) {
        if (!empty($options['smtp_host']) && !empty($options['smtp_port']) && !empty($options['smtp_auth']) && !empty($options['smtp_user']) && !empty($options['smtp_pass'])) {
            $smarty->assign('site_name', $options['site_name']);
            $smarty->assign('site_url', $options['site_url']);
            $smarty->assign('web_name', $row['web_name']);
            if ($web_status == 3) {
                $site_link = get_website_url($row['web_id'], true);
                $smarty->assign('site_link', $site_link);
                $mailbody = $smarty->fetch('audit_mail.html');
                sendmail($row['user_email'], '['.$options['site_name'].'] 网站已通过审核!', $mailbody);
            } elseif ($web_status == 4) {
                $smarty->assign('reject_reason', $reject_reason);
                $mailbody = $smarty->fetch('reject_mail.html');
                sendmail($row['user_email'], '['.$options['site_name'].'] 网站审核未通过', $mailbody);
            }
        }
        // 更新数据库(不包含 reject_reason)
        $DB->update($table, array('web_ispay' => $web_ispay, 'web_istop' => $web_istop, 'web_isbest' => $web_isbest, 'web_status' => $web_status), array('web_id' => $row['web_id']));
    }
    msgbox('网站属性设置成功!', $fileurl);
}

添加位置说明

  • 未通过原因的获取代码添加在 之后, 循环之前,直接从 获取值。if (empty($web_ids)) { ... }foreach$_POST['reject_reason']
  • 未通过原因的处理代码添加在邮件发送逻辑中,在 的条件分支内,将值赋值给 Smarty 变量用于邮件模板渲染。$web_status == 4
  • 不添加未通过原因到更新数据库的数组中,因此不会保存到数据库。

邮件模板

确保 模板文件存在并正确配置,用于发送审核未通过的邮件通知,包含未通过原因的内容。模板内容如下:新建reject_mail.html


<!DOCTYPE html>
<html>
<head>
<style type="text/css">
html {word-wrap: break-word;}
body {font: 14px arial, verdana, sans-serif; line-height: 25px; margin: 0; padding: 8px 10px;}
pre {
white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word;
}
</style>
</head>
<body>
<table cellpadding="0" cellspacing="0" width="100%" style="font-family: verdana, arial; margin: 0 auto; width: 650px;">
<tr>
<td style="background: #d9534f; color: #fff; font: bold 14px normal; line-height: 35px;">&nbsp;&nbsp;您提交在{#$site_name#}的网站审核未通过!</td>
</tr>
<tr>
<td style="border: solid 1px #ccc; font-size: 13px; line-height: 180%; padding: 20px;">
您好!<br>
很遗憾地通知您,您提交在{#$site_name#}的网站:{#$web_name#}, 未通过我们的审核!<br>
未通过原因:<br>
{#$reject_reason#}<br><br>
您可以根据上述原因进行修改后重新提交审核。<br><br>
本站网址:<a href="{#$site_url#}" target="_blank">{#$site_url#}</a><br>
</td>
</tr>
<tr>
<td style="background: #333; color: #fff; font-size: 12px; line-height: 180%; padding: 10px;">请注意:此邮件系 <a href="{#$site_url#}" target="_blank" style="color: #fff;">{#$site_name#}</a> 自动发送,请勿直接回复。<br>如果此邮件不是您请求的,请忽略并删除!</td>
</tr>
</table>
</body>
</html>

总结

通过以上修改,您可以在不存储未通过原因到数据库的情况下实现"审核不通过"功能的完整流程:

  • 管理员在前端表单中选择"审核不通过"状态并填写原因。
  • 后端接收原因并通过邮件发送给用户。
  • 不修改数据库结构,不保存原因数据。

关键添加位置

  • $action == 'saveedit':未通过原因的获取和邮件发送逻辑添加在 之后,邮件发送条件分支内。update_cache('archives');
  • $action == 'saveattr':未通过原因的获取添加在 之后,邮件发送逻辑添加在 循环内的邮件发送条件分支中。if (empty($web_ids)) { ... }foreach

© 版权声明

推荐站点

  • QR Online.ioQR Online.io

    Free online QR code generator supporting URL, text, contact info, WiFi and more. Customize colors, add logos, high-quality output.

    www.qronline.io
  • Temp Mail 365Temp Mail 365

    Temp Mail 365 provides instant temporary email addresses to protect your privacy and avoid spam. No registration required, 5-60 minute validity.

    temp-mail-365.com
  • 我的电视我的电视

    我的电视是一个在线观看高清影视电影的免费站点

    my0713.com
  • 优站库 - 新型分类目录优站库 - 新型分类目录

    一个集网站推荐、内容推荐于一体的宝藏之地。我们精心搜罗各类常用网站,构建起全面的网站目录。无论是学习提升所需的在线课程平台,还是休闲娱乐的影视音乐网站,亦或是商务办公的效率工具站点,都能在我们的分类大全中快速找到。同时,我们也是一个充满活力的建站交流社区。站长们在此分享经验、探讨技术,共同提升网站建设水平。作为网址导航,我们为你清晰分类,节省寻找优质网站的时间和精力。在这里,你无需再为找不到合适的网站而烦恼,只需轻轻一点,就能开启精彩的网络之旅。

    www.uzkoo.com
  • Bible Verse of the DayBible Verse of the Day

    Get your free Bible Verse of the Day

    verseoftheday.online