xaron/cloud-firewall

使用Cloudflare服务保护您的网站免受机器人/垃圾邮件/洪水攻击。

0.1.4.6 2020-07-30 09:43 UTC

This package is auto-updated.

Last update: 2024-09-18 16:38:15 UTC


README

使用Cloudflare服务保护您的网站免受机器人/垃圾邮件/洪水攻击,以及sql/xss注入攻击。

GitHub stars GitHub code size in bytes GitHub GitHub top language CodeFactor Grade GitHub issues

安装

composer require xaron/cloud-firewall

WHMCS模块

下载:https://github.com/0x5841524f4e/CloudFirewall/raw/master/CloudFirewallWHMCS.rar

将文件导出到您的WHMCS主目录。

示例

<?php
require_once __DIR__ . '/vendor/autoload.php';

use CF\CloudFirewall;

/*
Init CloudFirewall class.
*/
$firewall = new CloudFirewall('email_address', 'global_api_key', 'zone_id (Not required if already set in function parameter)');

/*
Change security level.
Actions: [essentially_off, low, medium, high, under_attack]
*/
$firewall->changeSecurityLevel('medium', 'zone_id (Not required if already set in constructor)');

/*
Create access rule.
Actions: [block, challenge, whitelist, js_challenge]
*/
$firewall->createAccessRule('31.13.37.31', 'challenge');

/*
Enabling block SQL injection attacks and it will ban from Cloudflare.
Parameters: sqlInjectionBlock(true if you want request ip ban from Cloudflare. default is true.)
*/
$firewall->sqlInjectionBlock();

/*
Enabling block XSS injection attacks and it will ban from Cloudflare.
Parameters: xssInjectionBlock(true if you want request ip ban from Cloudflare. default is true.)
*/
$firewall->xssInjectionBlock();

/*
Enabling block cookie steal attacks.
Parameters: cookieStealBlock(true if you want request ip ban from Cloudflare. default is false.)
*/
$firewall->cookieStealBlock();

/*
Enabling anti flood.
Parameters: antiFlood(requestPerSecond, badRequestChance, badRequestResetInXseconds, banFromCloudflare)
*/
$firewall->antiFlood(1, 3, 5, true);

/*
Get script execution time.
Info: Please write at the bottom of the page.
Usage: echo($firewall->benchmark());
*/
$firewall->benchmark();

要求

  • PHP >= 7.1.*
  • cURL扩展
  • OpenSSL扩展