合并分支 'akun' 到 'master'
Akun 查看合并请求 !1363
正在显示
1 个修改的文件
包含
130 行增加
和
0 行删除
| @@ -8,14 +8,18 @@ use App\Models\Devops\ServerConfig; | @@ -8,14 +8,18 @@ use App\Models\Devops\ServerConfig; | ||
| 8 | use App\Models\Devops\ServersIp; | 8 | use App\Models\Devops\ServersIp; |
| 9 | use App\Models\Domain\DomainCreateTask; | 9 | use App\Models\Domain\DomainCreateTask; |
| 10 | use App\Models\Domain\DomainInfo; | 10 | use App\Models\Domain\DomainInfo; |
| 11 | +use App\Models\Inquiry\InquiryInfo; | ||
| 11 | use App\Models\Product\Keyword; | 12 | use App\Models\Product\Keyword; |
| 12 | use App\Models\Project\DeployBuild; | 13 | use App\Models\Project\DeployBuild; |
| 14 | +use App\Models\Project\InquiryFilterConfig; | ||
| 13 | use App\Models\Project\Project; | 15 | use App\Models\Project\Project; |
| 14 | use App\Models\WebSetting\WebLanguage; | 16 | use App\Models\WebSetting\WebLanguage; |
| 15 | use App\Services\BatchExportService; | 17 | use App\Services\BatchExportService; |
| 16 | use App\Services\ProjectServer; | 18 | use App\Services\ProjectServer; |
| 17 | use Illuminate\Console\Command; | 19 | use Illuminate\Console\Command; |
| 18 | use Illuminate\Support\Facades\DB; | 20 | use Illuminate\Support\Facades\DB; |
| 21 | +use Illuminate\Support\Facades\URL; | ||
| 22 | +use Illuminate\Support\Str; | ||
| 19 | 23 | ||
| 20 | class Temp extends Command | 24 | class Temp extends Command |
| 21 | { | 25 | { |
| @@ -35,7 +39,133 @@ class Temp extends Command | @@ -35,7 +39,133 @@ class Temp extends Command | ||
| 35 | 39 | ||
| 36 | public function handle() | 40 | public function handle() |
| 37 | { | 41 | { |
| 42 | + $this->inquiry_filter(); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public function inquiry_filter() | ||
| 46 | + { | ||
| 47 | + $list = InquiryInfo::where('status', InquiryInfo::STATUS_INIT)->get(); | ||
| 48 | + | ||
| 49 | + foreach ($list as $data) { | ||
| 50 | + //邮箱和内容唯一值 | ||
| 51 | + $unique_sign = md5($data['email'] . $data['message']); | ||
| 52 | + | ||
| 53 | + $remark = $this->inquiryFilter($unique_sign, $data['country'], $data['ip'], $data['message'], $data['url'], $data['email'], $data['phone'], $data['name']); | ||
| 54 | + $status = $remark ? InquiryInfo::STATUS_INVALID : InquiryInfo::STATUS_INIT; | ||
| 55 | + | ||
| 56 | + $data->status = $status; | ||
| 57 | + $data->remark = $remark; | ||
| 58 | + $data->unique_sign = $unique_sign; | ||
| 59 | + $data->save(); | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * 过滤数据 | ||
| 65 | + * @param $unique_sign | ||
| 66 | + * @param $country | ||
| 67 | + * @param $ip | ||
| 68 | + * @param $message | ||
| 69 | + * @param $refer | ||
| 70 | + * @param $email | ||
| 71 | + * @param $phone | ||
| 72 | + * @param $name | ||
| 73 | + * @return string | ||
| 74 | + * @author Akun | ||
| 75 | + * @date 2025/03/06 15:09 | ||
| 76 | + */ | ||
| 77 | + public function inquiryFilter($unique_sign, $country, $ip, $message, $refer, $email, $phone, $name) | ||
| 78 | + { | ||
| 79 | + //邮箱和内容唯一性 | ||
| 80 | + if (InquiryInfo::where('unique_sign', $unique_sign)->first()) { | ||
| 81 | + return '邮箱内容重复过滤'; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + //国内ip | ||
| 85 | + if ($country == '中国') { | ||
| 86 | + return '中国内地过滤'; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + //QQ邮箱 | ||
| 90 | + if (substr($email, -6) == 'qq.com') { | ||
| 91 | + return 'QQ邮箱过滤'; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + //86开头的手机号 | ||
| 95 | + $num_phone = preg_replace('/\D/', '', $phone) ?? ''; // \D 匹配所有非数字字符 | ||
| 96 | + if (substr($num_phone, 0, 2) == '86') { | ||
| 97 | + return '86开头手机号过滤'; | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + //公共规则 | ||
| 101 | + $config = InquiryFilterConfig::getCacheInfoByProjectId(Project::DEMO_PROJECT_ID); | ||
| 102 | + //过滤国家 | ||
| 103 | + if (!empty($config['filter_countries']) && in_array($country, $config['filter_countries'])) { | ||
| 104 | + return '过滤国家:' . $country; | ||
| 105 | + } | ||
| 106 | + //过滤ip | ||
| 107 | + if (!empty($config['black_ips']) && in_array($ip, $config['black_ips'])) { | ||
| 108 | + return '过滤黑名单IP:' . $ip; | ||
| 109 | + } | ||
| 110 | + //过滤内容关键字 | ||
| 111 | + if (!empty($config['filter_contents'])) { | ||
| 112 | + foreach ($config['filter_contents'] as $filter_content) { | ||
| 113 | + //中文直接包含 | ||
| 114 | + if (preg_match("/^[\x{4e00}-\x{9fa5}]+$/u", $filter_content)) { | ||
| 115 | + if (Str::contains($message, $filter_content)) { | ||
| 116 | + return '过滤内容:' . $filter_content; | ||
| 117 | + } | ||
| 118 | + } else { | ||
| 119 | + //英文要指定词才过滤 | ||
| 120 | + if (preg_match("/\b" . preg_quote($filter_content, "/") . "\b/i", $message)) { | ||
| 121 | + return '过滤内容:' . $filter_content; | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + //过滤内容是否允许包含链接 | ||
| 127 | + if (isset($config['is_allow_link']) && $config['is_allow_link'] == 0) { | ||
| 128 | + if (Str::contains(strtolower($message), ['http://', 'https://', 'www.'])) { | ||
| 129 | + return '内容包含链接过滤'; | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + //过滤来源 | ||
| 133 | + if (!empty($config['filter_referers'])) { | ||
| 134 | + //只比较path路径 | ||
| 135 | + $paths = array_map(function ($v) { | ||
| 136 | + return trim(parse_url(Url::to($v), PHP_URL_PATH), '/'); | ||
| 137 | + }, $config['filter_referers']); | ||
| 138 | + | ||
| 139 | + if (in_array(trim(parse_url($refer, PHP_URL_PATH), '/'), $paths)) { | ||
| 140 | + return '过滤来源链接:' . $refer; | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | + //过滤邮箱 | ||
| 144 | + if (!empty($config['filter_emails'])) { | ||
| 145 | + foreach ($config['filter_emails'] as $filter_email) { | ||
| 146 | + if (Str::contains(strtolower($email), strtolower($filter_email))) { | ||
| 147 | + return '过滤邮箱:' . $filter_email; | ||
| 148 | + } | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + //过滤电话 | ||
| 152 | + if (!empty($config['filter_mobiles'])) { | ||
| 153 | + foreach ($config['filter_mobiles'] as $filter_mobile) { | ||
| 154 | + if (Str::contains(strtolower($phone), strtolower($filter_mobile))) { | ||
| 155 | + return '过滤电话:' . $filter_mobile; | ||
| 156 | + } | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | + //过滤姓名 | ||
| 160 | + if (!empty($config['filter_names'])) { | ||
| 161 | + foreach ($config['filter_names'] as $filter_name) { | ||
| 162 | + if (Str::contains(strtolower($name), strtolower($filter_name))) { | ||
| 163 | + return '过滤姓名:' . $filter_name; | ||
| 164 | + } | ||
| 165 | + } | ||
| 166 | + } | ||
| 38 | 167 | ||
| 168 | + return ''; | ||
| 39 | } | 169 | } |
| 40 | 170 | ||
| 41 | /** | 171 | /** |
-
请 注册 或 登录 后发表评论