First Commit
This commit is contained in:
Executable
+75
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Validation;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class ContentFilterRule implements Rule
|
||||
{
|
||||
private array $blockedPatterns;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->blockedPatterns = [
|
||||
'pornografia',
|
||||
'porn',
|
||||
'sexo',
|
||||
'sexual',
|
||||
'política',
|
||||
'politica',
|
||||
'partido',
|
||||
'eleição',
|
||||
'eleicao',
|
||||
'religião',
|
||||
'religiao',
|
||||
'crente',
|
||||
'ateu',
|
||||
'deus',
|
||||
'diabo',
|
||||
'preconceito',
|
||||
'racismo',
|
||||
'racista',
|
||||
'homofobia',
|
||||
'homofóbico',
|
||||
'transfobia',
|
||||
'xenofobia',
|
||||
'nazismo',
|
||||
'nazi',
|
||||
'fascismo',
|
||||
'fascista',
|
||||
'palavrão',
|
||||
'palavrao',
|
||||
'porra',
|
||||
'caralho',
|
||||
'merda',
|
||||
'puta',
|
||||
'cuzão',
|
||||
'cuzao',
|
||||
'viado',
|
||||
'bicha',
|
||||
'macaco',
|
||||
'senzala',
|
||||
'escravo',
|
||||
];
|
||||
}
|
||||
|
||||
public function passes($attribute, $value): bool
|
||||
{
|
||||
$normalized = mb_strtolower(trim($value));
|
||||
|
||||
foreach ($this->blockedPatterns as $pattern) {
|
||||
if (str_contains($normalized, $pattern)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function message(): string
|
||||
{
|
||||
return __('Your message contains prohibited content. Please do not use sensitive data, profanity, or topics such as pornography, politics, religion, or prejudice.');
|
||||
}
|
||||
}
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Validation;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class MathCaptchaRule implements Rule
|
||||
{
|
||||
public function passes($attribute, $value): bool
|
||||
{
|
||||
if (!Session::has('math_captcha_answer')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$expected = Session::get('math_captcha_answer');
|
||||
|
||||
Session::forget('math_captcha_answer');
|
||||
Session::forget('math_captcha_question');
|
||||
|
||||
return $value !== null && $value !== '' && (int) $value === (int) $expected;
|
||||
}
|
||||
|
||||
public function message(): string
|
||||
{
|
||||
return __('The captcha answer is incorrect. Please try again.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user