浏览代码

Add nekot rule

Visman 2 年之前
父节点
当前提交
00d8333b40
共有 1 个文件被更改,包括 29 次插入0 次删除
  1. 29 0
      app/Models/Validators/Nekot.php

+ 29 - 0
app/Models/Validators/Nekot.php

@@ -0,0 +1,29 @@
+<?php
+/**
+ * This file is part of the ForkBB <https://github.com/forkbb>.
+ *
+ * @copyright (c) Visman <mio.visman@yandex.ru, https://github.com/MioVisman>
+ * @license   The MIT License (MIT)
+ */
+
+declare(strict_types=1);
+
+namespace ForkBB\Models\Validators;
+
+use ForkBB\Core\RulesValidator;
+use ForkBB\Core\Validator;
+
+class Nekot extends RulesValidator
+{
+    public function nekot(Validator $v, string $value): string
+    {
+        if (
+            '' == $value
+            || \substr(\preg_replace('%\D+%', '', $v->token), 0, 6) !== $value
+        ) {
+            $v->addError('Javascript disabled or bot', FORK_MESS_ERR);
+        }
+
+        return $value;
+    }
+}