Table of Contents
回复内容:
Home Backend Development PHP Tutorial 用户频繁请求一个数据,怎样来设计验证码屏蔽

用户频繁请求一个数据,怎样来设计验证码屏蔽

Jun 06, 2016 pm 08:44 PM
php

比如一个SNS社区中,一个用户不停添加好友,怀疑是机器人的行为,假设该机器人在某一时间内每隔3秒就发送一个好友请求,系统怎样来辨别这是机器人的行为然后生成验证码加以阻止,想了很久都没想到很好的解决方法

回复内容:

比如一个SNS社区中,一个用户不停添加好友,怀疑是机器人的行为,假设该机器人在某一时间内每隔3秒就发送一个好友请求,系统怎样来辨别这是机器人的行为然后生成验证码加以阻止,想了很久都没想到很好的解决方法

我觉得首先我们不用辨别是不是机器人,这些敏感操作最好带api key。对于该API根据uid或者api key设置 rate limit,例如1分钟不能发送加好友数超过20个。当超过时返回错误提示。假如它还继续发送大量请求,那么机器人无疑,完全禁止该uid的请求。

function 添加朋友(){
    if(没登陆) die;
    if(当前时间-上次添加好友时间>3){
        继续添加好友
    }
    else{
        你添加的太快啦
    }
}
Copy after login

用图片验证码,如果是机器人,他破解需要时间。再限定一分钟同一账号提交数据的次数。

像腾讯,百度的验证码基本可以屏蔽%95的机器人了,网上有类似开源的验证码类。
制定一个规则,比如每个用户一分钟内只能添加10个好友(1分钟内超过5个时出现验证码),每天增加的好友上线为100个(超过50个时出现验证码)。把这些数据存到memcache中,每次用户发送添加好友的请求先对比下是否符合规则

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles