|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Controllers\BasePageController; |
|
6
|
|
|
use App\Models\Category; |
|
7
|
|
|
use Blacklight\Binaries; |
|
8
|
|
|
use Illuminate\Http\Request; |
|
9
|
|
|
|
|
10
|
|
|
class AdminBlacklistController extends BasePageController |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @throws \Exception |
|
14
|
|
|
*/ |
|
15
|
|
|
public function index() |
|
16
|
|
|
{ |
|
17
|
|
|
$this->setAdminPrefs(); |
|
18
|
|
|
$binaries = new Binaries(); |
|
19
|
|
|
|
|
20
|
|
|
$meta_title = $title = 'Binary Black/White List'; |
|
21
|
|
|
|
|
22
|
|
|
$binlist = $binaries->getBlacklist(false); |
|
23
|
|
|
$this->smarty->assign('binlist', $binlist); |
|
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
$content = $this->smarty->fetch('binaryblacklist-list.tpl'); |
|
|
|
|
|
|
26
|
|
|
$this->smarty->assign(compact('title', 'meta_title', 'content')); |
|
27
|
|
|
$this->adminrender(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param \Illuminate\Http\Request $request |
|
32
|
|
|
* |
|
33
|
|
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |
|
34
|
|
|
* @throws \Exception |
|
35
|
|
|
*/ |
|
36
|
|
|
public function edit(Request $request) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->setAdminPrefs(); |
|
39
|
|
|
$binaries = new Binaries(['Settings' => null]); |
|
40
|
|
|
$error = ''; |
|
41
|
|
|
$regex = ['id' => '', 'groupname' => '', 'regex' => '', 'description' => '', 'msgcol' => 1, 'status' => 1, 'optype' => 1]; |
|
42
|
|
|
$meta_title = $title = 'Binary Black/White list'; |
|
43
|
|
|
|
|
44
|
|
|
switch ($request->input('action') ?? 'view') { |
|
45
|
|
|
case 'submit': |
|
46
|
|
|
if ($request->input('groupname') === '') { |
|
47
|
|
|
$error = 'Group must be a valid usenet group'; |
|
48
|
|
|
break; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
if ($request->input('regex') === '') { |
|
52
|
|
|
$error = 'Regex cannot be empty'; |
|
53
|
|
|
break; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
if (empty($request->input('id'))) { |
|
57
|
|
|
$binaries->addBlacklist($request->all()); |
|
58
|
|
|
} else { |
|
59
|
|
|
$binaries->updateBlacklist($request->all()); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
return redirect('admin/binaryblacklist-list'); |
|
63
|
|
|
break; |
|
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
case 'addtest': |
|
66
|
|
|
if ($request->has('regex') && $request->has('groupname')) { |
|
67
|
|
|
$regex += [ |
|
68
|
|
|
'groupname' => $request->input('groupname'), |
|
69
|
|
|
'regex' => $request->input('regex'), |
|
70
|
|
|
'ordinal' => 1, |
|
71
|
|
|
'status' => 1, |
|
72
|
|
|
]; |
|
73
|
|
|
} |
|
74
|
|
|
break; |
|
75
|
|
|
|
|
76
|
|
|
case 'view': |
|
77
|
|
|
default: |
|
78
|
|
|
if ($request->has('id')) { |
|
79
|
|
|
$title = 'Binary Black/Whitelist Edit'; |
|
80
|
|
|
$regex = $binaries->getBlacklistByID($request->input('id')); |
|
81
|
|
|
} else { |
|
82
|
|
|
$title = 'Binary Black/Whitelist Add'; |
|
83
|
|
|
$regex += [ |
|
84
|
|
|
'status' => 1, |
|
85
|
|
|
'optype' => 1, |
|
86
|
|
|
'msgcol' => 1, |
|
87
|
|
|
]; |
|
88
|
|
|
} |
|
89
|
|
|
break; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
$this->smarty->assign( |
|
93
|
|
|
[ |
|
94
|
|
|
'error' => $error, |
|
95
|
|
|
'regex' => $regex, |
|
96
|
|
|
'status_ids' => [Category::STATUS_ACTIVE, Category::STATUS_INACTIVE], |
|
97
|
|
|
'status_names' => ['Yes', 'No'], |
|
98
|
|
|
'optype_ids' => [1, 2], |
|
99
|
|
|
'optype_names' => ['Black', 'White'], |
|
100
|
|
|
'msgcol_ids' => [ |
|
101
|
|
|
Binaries::BLACKLIST_FIELD_SUBJECT, |
|
102
|
|
|
Binaries::BLACKLIST_FIELD_FROM, |
|
103
|
|
|
Binaries::BLACKLIST_FIELD_MESSAGEID, |
|
104
|
|
|
], |
|
105
|
|
|
'msgcol_names' => ['Subject', 'Poster', 'MessageId'], |
|
106
|
|
|
] |
|
107
|
|
|
); |
|
108
|
|
|
|
|
109
|
|
|
$content = $this->smarty->fetch('binaryblacklist-edit.tpl'); |
|
110
|
|
|
$this->smarty->assign(compact('title', 'meta_title', 'content')); |
|
111
|
|
|
$this->adminrender(); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.