• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visavi / rotor / 28323582235

28 Jun 2026 01:20PM UTC coverage: 16.474% (+0.06%) from 16.419%
28323582235

push

github

visavi
Переход на datetime

19 of 66 new or added lines in 23 files covered. (28.79%)

9 existing lines in 8 files now uncovered.

984 of 5973 relevant lines covered (16.47%)

2.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

8.33
/app/Http/Controllers/Admin/BlacklistController.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace App\Http\Controllers\Admin;
6

7
use App\Classes\Validator;
8
use App\Models\BlackList;
9
use Illuminate\Http\RedirectResponse;
10
use Illuminate\Http\Request;
11
use Illuminate\Support\Str;
12
use Illuminate\View\View;
13

14
class BlacklistController extends AdminController
15
{
16
    private string $type;
17

18
    /**
19
     * Конструктор
20
     */
21
    public function __construct(Request $request)
3✔
22
    {
23
        $types = ['email', 'login', 'domain'];
3✔
24

25
        $this->type = $request->input('type', 'email');
3✔
26

27
        if (! in_array($this->type, $types, true)) {
3✔
28
            abort(404, __('admin.blacklists.type_not_found'));
×
29
        }
30
    }
31

32
    /**
33
     * Главная страница
34
     */
35
    public function index(Request $request, Validator $validator): View|RedirectResponse
×
36
    {
37
        $type = $this->type;
×
38

39
        if ($request->isMethod('post')) {
×
40
            $value = Str::lower((string) $request->input('value'));
×
41

42
            $validator->length($value, 1, 100, ['value' => __('validator.text')]);
×
43

44
            if ($type === 'email') {
×
45
                $validator->regex($value, '#^[a-z0-9_.-]+@[a-z0-9_.-]+(\.[a-z0-9]+)+$#', ['value' => __('validator.email')]);
×
46
            }
47

48
            if ($type === 'login') {
×
49
                $validator->regex($value, '|^[a-z0-9\-]+$|', ['value' => __('admin.blacklists.invalid_login')])
×
50
                    ->length($value, 3, 20, ['value' => __('validator.text')]);
×
51
            }
52

53
            if ($type === 'domain') {
×
54
                if (! preg_match('#^https?://#i', $value)) {
×
55
                    $value = 'https://' . $value;
×
56
                }
57
                $value = parse_url(strtolower($value), PHP_URL_HOST);
×
58

59
                $validator->regex($value, '#^[а-яa-z0-9_.-]+(\.[а-яa-z0-9/]+)+$#u', ['value' => __('validator.site')]);
×
60
            }
61

62
            $validator->false(BlackList::isBlacklisted($type, $value), ['value' => __('main.record_exists')]);
×
63

64
            if ($validator->isValid()) {
×
65
                BlackList::query()->create([
×
NEW
66
                    'type'    => $type,
×
NEW
67
                    'value'   => $value,
×
NEW
68
                    'user_id' => getUser('id'),
×
UNCOV
69
                ]);
×
70

71
                setFlash('success', __('main.record_added_success'));
×
72

73
                return redirect('admin/blacklists?type=' . $type);
×
74
            }
75

76
            setInput($request->all());
×
77
            setFlash('danger', $validator->getErrors());
×
78
        }
79

80
        $lists = BlackList::query()
×
81
            ->where('type', $type)
×
82
            ->orderByDesc('created_at')
×
83
            ->with('user')
×
84
            ->paginate(setting('blacklist'))
×
85
            ->appends(['type' => $type]);
×
86

87
        return view('admin/blacklists/index', compact('lists', 'type'));
×
88
    }
89

90
    /**
91
     * Удаление записей
92
     */
93
    public function delete(Request $request, Validator $validator): RedirectResponse
×
94
    {
95
        $page = int($request->input('page', 1));
×
96
        $del = intar($request->input('del'));
×
97
        $type = $this->type;
×
98

99
        $validator->true($del, __('validator.deletion'));
×
100

101
        if ($validator->isValid()) {
×
102
            BlackList::query()->where('type', $type)->whereIn('id', $del)->delete();
×
103

104
            setFlash('success', __('main.records_deleted_success'));
×
105
        } else {
106
            setFlash('danger', $validator->getErrors());
×
107
        }
108

109
        return redirect('admin/blacklists?type=' . $type . '&page=' . $page);
×
110
    }
111
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc