给问题加一个自动清理垃圾问题的方法

Alu
Alu This guy is lazy,Introduction has not been set

0 People liked this article · 2555 views

你的网站是不是也被灌水机攻击了,删问题删的手软,以下方法可以让它自动清理:

1、禁止灌水发提问的用户(这是关键)

2、在程序目录下的 models\question.php 代码最下面 } 前添加:

    public function delete_user_question()
    {
        if (AWS_APP::cache()->get('delete_question_num')) {
            return false;
        }
        $uids = $ids = array();
        if (! $uids = AWS_APP::cache()->get('delete_user_question')) {
            $time = time() - 86400 * 90;
            foreach($this->fetch_all('users', 'reg_time>' . $time . ' AND integral>100 AND forbidden>0', '', null, 1000) as $value) {
                $uids[] = $value['uid'];
            }
            AWS_APP::cache()->set('delete_user_question', $uids, 86400);
        }
        if ($question = $this->fetch_all('question', "published_uid IN(" . implode(',', $uids) . ")", '', 1000))
        {
            foreach($question as $key => $value) {
                $ids[] = $value['question_id'];
                $this->remove_question($value['question_id']);
            }
            if (($num = count($ids)) <= 0) {
                AWS_APP::cache()->set('delete_question_num', 100);
            }
        }
    }

3、在计划任务里添加 models\crond.php

// 每半分钟执行 或 // 每分钟执行 或自行选择周期

$this->model('question')->delete_user_question();

 

 

Published on 2019-07-01 19:42

Disclaimers:

This document is written by Alu Original published on WeCenter ,The copyright belongs to the author。

Log in,More exciting content waiting for you to find,Contribute wonderful answers,Participate in comment interaction

go Sign in! No accountgoregister

龙天
2019-07-14 18:04
就是说还要人工禁止,不能自动判断这个是不是灌水的
Alu
2019-07-09 19:56
要禁止才会删哦
龙天
2019-07-09 12:43
这个挺好, 发贴多的普通用户会不会被封了,删贴?
imningfeng
2019-07-01 20:26
把发帖的用户删了,就OK了