FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

订阅功能优化 · githubseefar/SSRPanel@a17ef3f · GitHub

Commit a17ef3f

Browse files
committed
订阅功能优化
1 parent 9a96fe8 commit a17ef3f

5 files changed

Lines changed: 84 additions & 50 deletions

File tree

‎app/Http/Controllers/SubscribeController.php‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ public function index(Request $request, $code)
5959
exit($this->noneNode());
6060
}
6161

62-
$nodeList = SsNode::query()
63-
->selectRaw('ss_node.*')
64-
->leftjoin("ss_node_label", "ss_node.id", "=", "ss_node_label.node_id")
65-
->where('ss_node.type', 1)
66-
->where('ss_node.status', 1)
62+
$query = SsNode::query()->selectRaw('ss_node.*')->leftjoin("ss_node_label", "ss_node.id", "=", "ss_node_label.node_id");
63+
64+
// 启用混合订阅时,加入V2Ray节点,未启用时仅下发SSR节点信息
65+
if (!self::$systemConfig['mix_subscribe']) {
66+
$query->where('ss_node.type', 1);
67+
}
68+
69+
$nodeList = $query->where('ss_node.status', 1)
6770
->where('ss_node.is_subscribe', 1)
6871
->whereIn('ss_node_label.label_id', $userLabelIds)
6972
->groupBy('ss_node.id')
@@ -76,8 +79,10 @@ public function index(Request $request, $code)
7679
}
7780

7881
// 打乱数组
79-
if (self::$systemConfig['subscribe_max']) {
80-
shuffle($nodeList);
82+
if (self::$systemConfig['rand_subscribe']) {
83+
if (self::$systemConfig['subscribe_max']) {
84+
shuffle($nodeList);
85+
}
8186
}
8287

8388
// 控制客户端最多获取节点数

‎app/Http/Middleware/isForbidden.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function handle($request, Closure $next)
2525
if (Agent::isRobot()) {
2626
Log::info("识别到机器人访问(" . getClientIp() . ")");
2727

28-
return response()->view('error.403', [], 403);
28+
return response()->view('error.404', [], 404);
2929
}
3030
}
3131

‎resources/views/admin/system.blade.php‎

Lines changed: 64 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
<label for="is_forbid_robot" class="col-md-3 control-label">阻止机器人访问</label>
149149
<div class="col-md-9">
150150
<input type="checkbox" class="make-switch" @if($is_forbid_robot) checked @endif id="is_forbid_robot" data-on-color="success" data-off-color="danger" data-on-text="启用" data-off-text="关闭">
151-
<span class="help-block"> 如果是机器人、爬虫、代理访问网站则会抛出403错误 </span>
151+
<span class="help-block"> 如果是机器人、爬虫、代理访问网站则会抛出404错误 </span>
152152
</div>
153153
</div>
154154
<div class="col-md-6">
@@ -295,6 +295,32 @@
295295
</div>
296296
</div>
297297
</div>
298+
<div class="form-group">
299+
<div class="col-md-6">
300+
<label for="initial_labels_for_user" class="col-md-3 control-label">用户初始标签</label>
301+
<div class="col-md-9">
302+
<select id="initial_labels_for_user" class="form-control select2-multiple" name="initial_labels_for_user" multiple="multiple">
303+
@foreach($label_list as $label)
304+
<option value="{{$label->id}}" @if(in_array($label->id, explode(',', $initial_labels_for_user))) selected @endif>{{$label->name}}</option>
305+
@endforeach
306+
</select>
307+
<span class="help-block"> 注册用户时的初始标签 </span>
308+
</div>
309+
</div>
310+
<div class="col-md-6">
311+
<label for="goods_purchase_limit_strategy" class="col-md-3 control-label">商品限购</label>
312+
<div class="col-md-9">
313+
<select id="goods_purchase_limit_strategy" class="form-control select2" name="goods_purchase_limit_strategy">
314+
<option value="none" @if($goods_purchase_limit_strategy == 'none') selected @endif>不限制</option>
315+
<option value="package" @if($goods_purchase_limit_strategy == 'package') selected @endif>仅限套餐</option>
316+
<option value="free" @if($goods_purchase_limit_strategy == 'free') selected @endif>仅限免费商品</option>
317+
<option value="package&free" @if($goods_purchase_limit_strategy == 'package&free') selected @endif>限套餐和免费商品</option>
318+
<option value="all" @if($goods_purchase_limit_strategy == 'all') selected @endif>限全部商品</option>
319+
</select>
320+
<span class="help-block"> 是否限制用户重复购买商品,限制后用户不可重复购买已购买的、尚在有效期的商品 </span>
321+
</div>
322+
</div>
323+
</div>
298324
<div class="form-group">
299325
<div class="col-md-6">
300326
<label for="subscribe_domain" class="col-md-3 control-label">节点订阅地址</label>
@@ -317,57 +343,23 @@
317343
<button class="btn btn-success" type="button" onclick="setSubscribeMax()">修改</button>
318344
</span>
319345
</div>
320-
<span class="help-block"> 客户端订阅时随机取得几个节点 </span>
346+
<span class="help-block"> 客户端订阅时取得几个节点 </span>
321347
</div>
322348
</div>
323349
</div>
324350
<div class="form-group">
325351
<div class="col-md-6">
326-
<label for="initial_labels_for_user" class="col-md-3 control-label">用户初始标签</label>
352+
<label for="mix_subscribe" class="col-md-3 control-label">混合订阅</label>
327353
<div class="col-md-9">
328-
<select id="initial_labels_for_user" class="form-control select2-multiple" name="initial_labels_for_user" multiple="multiple">
329-
@foreach($label_list as $label)
330-
<option value="{{$label->id}}"
331-
@if (in_array($label->id, explode(',', $initial_labels_for_user)))
332-
selected
333-
@endif
334-
>{{$label->name}}</option>
335-
@endforeach
336-
</select>
337-
<span class="help-block"> 注册用户时的初始标签 </span>
354+
<input type="checkbox" class="make-switch" @if($mix_subscribe) checked @endif id="mix_subscribe" data-on-color="success" data-off-color="danger" data-on-text="启用" data-off-text="关闭">
355+
<span class="help-block"> 启用后,订阅信息中将包含V2Ray节点信息(Vmess) </span>
338356
</div>
339357
</div>
340358
<div class="col-md-6">
341-
<label for="goods_purchase_limit_strategy" class="col-md-3 control-label">商品限购</label>
359+
<label for="rand_subscribe" class="col-md-3 control-label">随机订阅</label>
342360
<div class="col-md-9">
343-
<select id="goods_purchase_limit_strategy" class="form-control select2" name="goods_purchase_limit_strategy">
344-
<option value="none"
345-
@if ($goods_purchase_limit_strategy == 'none')
346-
selected
347-
@endif
348-
>不限制</option>
349-
<option value="package"
350-
@if ($goods_purchase_limit_strategy == 'package')
351-
selected
352-
@endif
353-
>仅限套餐</option>
354-
<option value="free"
355-
@if ($goods_purchase_limit_strategy == 'free')
356-
selected
357-
@endif
358-
>仅限免费商品</option>
359-
<option value="package&free"
360-
@if ($goods_purchase_limit_strategy == 'package&free')
361-
selected
362-
@endif
363-
>限套餐和免费商品</option>
364-
<option value="all"
365-
@if ($goods_purchase_limit_strategy == 'all')
366-
selected
367-
@endif
368-
>限全部商品</option>
369-
</select>
370-
<span class="help-block"> 是否限制用户重复购买商品,限制后用户不可重复购买已购买的、尚在有效期的商品 </span>
361+
<input type="checkbox" class="make-switch" @if($rand_subscribe) checked @endif id="rand_subscribe" data-on-color="success" data-off-color="danger" data-on-text="启用" data-off-text="关闭">
362+
<span class="help-block"> 启用后,订阅时将随机返回节点信息,否则按节点排序返回 </span>
371363
</div>
372364
</div>
373365
</div>
@@ -1145,6 +1137,36 @@
11451137
}
11461138
});
11471139
1140+
// 启用、禁用混合订阅
1141+
$('#mix_subscribe').on({
1142+
'switchChange.bootstrapSwitch': function(event, state) {
1143+
var mix_subscribe = state ? 1 : 0;
1144+
1145+
$.post("{{url('admin/setConfig')}}", {_token:'{{csrf_token()}}', name:'mix_subscribe', value:mix_subscribe}, function (ret) {
1146+
layer.msg(ret.message, {time:1000}, function() {
1147+
if (ret.status == 'fail') {
1148+
window.location.reload();
1149+
}
1150+
});
1151+
});
1152+
}
1153+
});
1154+
1155+
// 启用、禁用随机订阅
1156+
$('#rand_subscribe').on({
1157+
'switchChange.bootstrapSwitch': function(event, state) {
1158+
var rand_subscribe = state ? 1 : 0;
1159+
1160+
$.post("{{url('admin/setConfig')}}", {_token:'{{csrf_token()}}', name:'rand_subscribe', value:rand_subscribe}, function (ret) {
1161+
layer.msg(ret.message, {time:1000}, function() {
1162+
if (ret.status == 'fail') {
1163+
window.location.reload();
1164+
}
1165+
});
1166+
});
1167+
}
1168+
});
1169+
11481170
// 启用、禁用PushBear
11491171
$('#is_push_bear').on({
11501172
'switchChange.bootstrapSwitch': function(event, state) {

‎sql/db.sql‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ INSERT INTO `config` VALUES ('69', 'is_forbid_china', 0);
359359
INSERT INTO `config` VALUES ('70', 'is_forbid_oversea', 0);
360360
INSERT INTO `config` VALUES ('71', 'is_verify_register', 0);
361361
INSERT INTO `config` VALUES ('72', 'node_daily_report', 0);
362+
INSERT INTO `config` values ('73', 'mix_subscribe', 0);
363+
INSERT INTO `config` values ('74', 'rand_subscribe', 0);
362364

363365

364366
-- ----------------------------

‎sql/update/20181204.sql‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- 混合订阅
2+
INSERT INTO `config` values ('73', 'mix_subscribe', 0);
3+
4+
-- 随机订阅
5+
INSERT INTO `config` values ('74', 'rand_subscribe', 0);

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL