|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Controllers\BasePageController; |
|
6
|
|
|
use App\Models\Sharing; |
|
7
|
|
|
use App\Models\SharingSite; |
|
8
|
|
|
use Illuminate\Http\Request; |
|
9
|
|
|
|
|
10
|
|
|
class AdminSharingController extends BasePageController |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @param \Illuminate\Http\Request $request |
|
14
|
|
|
* |
|
15
|
|
|
* @throws \Exception |
|
16
|
|
|
*/ |
|
17
|
|
|
public function index(Request $request) |
|
18
|
|
|
{ |
|
19
|
|
|
$this->setAdminPrefs(); |
|
20
|
|
|
|
|
21
|
|
|
$meta_title = $title = 'Sharing Settings'; |
|
22
|
|
|
|
|
23
|
|
|
$allSites = SharingSite::query()->orderByDesc('id')->paginate(config('nntmux.items_per_cover_page')); |
|
24
|
|
|
if ($allSites->total() === 0) { |
|
25
|
|
|
$allSites = false; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
$ourSite = Sharing::query()->first(); |
|
29
|
|
|
|
|
30
|
|
|
if (! empty($request->all())) { |
|
31
|
|
|
if (! empty($request->input('sharing_name')) && ! preg_match('/\s+/', $request->input('sharing_name')) && strlen($request->input('sharing_name')) < 255) { |
|
32
|
|
|
$site_name = trim($request->input('sharing_name')); |
|
33
|
|
|
} else { |
|
34
|
|
|
$site_name = $ourSite['site_name']; |
|
35
|
|
|
} |
|
36
|
|
|
if (! empty($request->input('sharing_maxpush')) && is_numeric($request->input('sharing_maxpush'))) { |
|
37
|
|
|
$max_push = trim($request->input('sharing_maxpush')); |
|
38
|
|
|
} else { |
|
39
|
|
|
$max_push = $ourSite['max_push']; |
|
40
|
|
|
} |
|
41
|
|
|
if (! empty($request->input('sharing_maxpoll')) && is_numeric($request->input('sharing_maxpush'))) { |
|
42
|
|
|
$max_pull = trim($request->input('sharing_maxpoll')); |
|
43
|
|
|
} else { |
|
44
|
|
|
$max_pull = $ourSite['max_pull']; |
|
45
|
|
|
} |
|
46
|
|
|
if (! empty($request->input('sharing_maxdownload')) && is_numeric($request->input('sharing_maxdownload'))) { |
|
47
|
|
|
$max_download = trim($request->input('sharing_maxdownload')); |
|
48
|
|
|
} else { |
|
49
|
|
|
$max_download = $ourSite['max_download']; |
|
50
|
|
|
} |
|
51
|
|
|
Sharing::query() |
|
52
|
|
|
->update(compact('site_name', 'max_push', 'max_pull', 'max_download')); |
|
53
|
|
|
|
|
54
|
|
|
$ourSite = $ourSite = Sharing::query()->first(); |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$this->smarty->assign(['local' => $ourSite, 'sites' => $allSites]); |
|
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
$content = $this->smarty->fetch('sharing.tpl'); |
|
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
$this->smarty->assign(compact('title', 'meta_title', 'content')); |
|
62
|
|
|
$this->adminrender(); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|