admin 7 лет назад
Родитель
Сommit
a17ef3fdfc

+ 12 - 7
app/Http/Controllers/SubscribeController.php

@@ -59,11 +59,14 @@ class SubscribeController extends Controller
             exit($this->noneNode());
         }
 
-        $nodeList = SsNode::query()
-            ->selectRaw('ss_node.*')
-            ->leftjoin("ss_node_label", "ss_node.id", "=", "ss_node_label.node_id")
-            ->where('ss_node.type', 1)
-            ->where('ss_node.status', 1)
+        $query = SsNode::query()->selectRaw('ss_node.*')->leftjoin("ss_node_label", "ss_node.id", "=", "ss_node_label.node_id");
+
+        // 启用混合订阅时,加入V2Ray节点,未启用时仅下发SSR节点信息
+        if (!self::$systemConfig['mix_subscribe']) {
+            $query->where('ss_node.type', 1);
+        }
+
+        $nodeList = $query->where('ss_node.status', 1)
             ->where('ss_node.is_subscribe', 1)
             ->whereIn('ss_node_label.label_id', $userLabelIds)
             ->groupBy('ss_node.id')
@@ -76,8 +79,10 @@ class SubscribeController extends Controller
         }
 
         // 打乱数组
-        if (self::$systemConfig['subscribe_max']) {
-            shuffle($nodeList);
+        if (self::$systemConfig['rand_subscribe']) {
+            if (self::$systemConfig['subscribe_max']) {
+                shuffle($nodeList);
+            }
         }
 
         // 控制客户端最多获取节点数

+ 1 - 1
app/Http/Middleware/isForbidden.php

@@ -25,7 +25,7 @@ class isForbidden
             if (Agent::isRobot()) {
                 Log::info("识别到机器人访问(" . getClientIp() . ")");
 
-                return response()->view('error.403', [], 403);
+                return response()->view('error.404', [], 404);
             }
         }
 

+ 64 - 42
resources/views/admin/system.blade.php

@@ -148,7 +148,7 @@
                                                             <label for="is_forbid_robot" class="col-md-3 control-label">阻止机器人访问</label>
                                                             <div class="col-md-9">
                                                                 <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="关闭">
-                                                                <span class="help-block"> 如果是机器人、爬虫、代理访问网站则会抛出403错误 </span>
+                                                                <span class="help-block"> 如果是机器人、爬虫、代理访问网站则会抛出404错误 </span>
                                                             </div>
                                                         </div>
                                                         <div class="col-md-6">
@@ -295,6 +295,32 @@
                                                             </div>
                                                         </div>
                                                     </div>
+                                                    <div class="form-group">
+                                                        <div class="col-md-6">
+                                                            <label for="initial_labels_for_user" class="col-md-3 control-label">用户初始标签</label>
+                                                            <div class="col-md-9">
+                                                                <select id="initial_labels_for_user" class="form-control select2-multiple" name="initial_labels_for_user" multiple="multiple">
+                                                                    @foreach($label_list as $label)
+                                                                        <option value="{{$label->id}}" @if(in_array($label->id, explode(',', $initial_labels_for_user))) selected @endif>{{$label->name}}</option>
+                                                                    @endforeach
+                                                                </select>
+                                                                <span class="help-block"> 注册用户时的初始标签 </span>
+                                                            </div>
+                                                        </div>
+                                                        <div class="col-md-6">
+                                                            <label for="goods_purchase_limit_strategy" class="col-md-3 control-label">商品限购</label>
+                                                            <div class="col-md-9">
+                                                                <select id="goods_purchase_limit_strategy" class="form-control select2" name="goods_purchase_limit_strategy">
+                                                                    <option value="none" @if($goods_purchase_limit_strategy == 'none') selected @endif>不限制</option>
+                                                                    <option value="package" @if($goods_purchase_limit_strategy == 'package') selected @endif>仅限套餐</option>
+                                                                    <option value="free" @if($goods_purchase_limit_strategy == 'free') selected @endif>仅限免费商品</option>
+                                                                    <option value="package&free" @if($goods_purchase_limit_strategy == 'package&free') selected @endif>限套餐和免费商品</option>
+                                                                    <option value="all" @if($goods_purchase_limit_strategy == 'all') selected @endif>限全部商品</option>
+                                                                </select>
+                                                                <span class="help-block"> 是否限制用户重复购买商品,限制后用户不可重复购买已购买的、尚在有效期的商品 </span>
+                                                            </div>
+                                                        </div>
+                                                    </div>
                                                     <div class="form-group">
                                                         <div class="col-md-6">
                                                             <label for="subscribe_domain" class="col-md-3 control-label">节点订阅地址</label>
@@ -317,57 +343,23 @@
                                                                         <button class="btn btn-success" type="button" onclick="setSubscribeMax()">修改</button>
                                                                     </span>
                                                                 </div>
-                                                                <span class="help-block"> 客户端订阅时随机取得几个节点 </span>
+                                                                <span class="help-block"> 客户端订阅时取得几个节点 </span>
                                                             </div>
                                                         </div>
                                                     </div>
                                                     <div class="form-group">
                                                         <div class="col-md-6">
-                                                            <label for="initial_labels_for_user" class="col-md-3 control-label">用户初始标签</label>
+                                                            <label for="mix_subscribe" class="col-md-3 control-label">混合订阅</label>
                                                             <div class="col-md-9">
-                                                                <select id="initial_labels_for_user" class="form-control select2-multiple" name="initial_labels_for_user" multiple="multiple">
-                                                                    @foreach($label_list as $label)
-                                                                        <option value="{{$label->id}}"
-                                                                            @if (in_array($label->id, explode(',', $initial_labels_for_user)))
-                                                                            selected
-                                                                            @endif
-                                                                        >{{$label->name}}</option>
-                                                                    @endforeach
-                                                                </select>
-                                                                <span class="help-block"> 注册用户时的初始标签 </span>
+                                                                <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="关闭">
+                                                                <span class="help-block"> 启用后,订阅信息中将包含V2Ray节点信息(Vmess) </span>
                                                             </div>
                                                         </div>
                                                         <div class="col-md-6">
-                                                            <label for="goods_purchase_limit_strategy" class="col-md-3 control-label">商品限购</label>
+                                                            <label for="rand_subscribe" class="col-md-3 control-label">随机订阅</label>
                                                             <div class="col-md-9">
-                                                                <select id="goods_purchase_limit_strategy" class="form-control select2" name="goods_purchase_limit_strategy">
-                                                                    <option value="none"
-                                                                            @if ($goods_purchase_limit_strategy == 'none')
-                                                                            selected
-                                                                            @endif
-                                                                    >不限制</option>
-                                                                    <option value="package"
-                                                                            @if ($goods_purchase_limit_strategy == 'package')
-                                                                            selected
-                                                                            @endif
-                                                                    >仅限套餐</option>
-                                                                    <option value="free"
-                                                                            @if ($goods_purchase_limit_strategy == 'free')
-                                                                            selected
-                                                                            @endif
-                                                                    >仅限免费商品</option>
-                                                                    <option value="package&free"
-                                                                            @if ($goods_purchase_limit_strategy == 'package&free')
-                                                                            selected
-                                                                            @endif
-                                                                    >限套餐和免费商品</option>
-                                                                    <option value="all"
-                                                                            @if ($goods_purchase_limit_strategy == 'all')
-                                                                            selected
-                                                                            @endif
-                                                                    >限全部商品</option>
-                                                                </select>
-                                                                <span class="help-block"> 是否限制用户重复购买商品,限制后用户不可重复购买已购买的、尚在有效期的商品 </span>
+                                                                <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="关闭">
+                                                                <span class="help-block"> 启用后,订阅时将随机返回节点信息,否则按节点排序返回 </span>
                                                             </div>
                                                         </div>
                                                     </div>
@@ -1145,6 +1137,36 @@
             }
         });
 
+        // 启用、禁用混合订阅
+        $('#mix_subscribe').on({
+            'switchChange.bootstrapSwitch': function(event, state) {
+                var mix_subscribe = state ? 1 : 0;
+
+                $.post("{{url('admin/setConfig')}}", {_token:'{{csrf_token()}}', name:'mix_subscribe', value:mix_subscribe}, function (ret) {
+                    layer.msg(ret.message, {time:1000}, function() {
+                        if (ret.status == 'fail') {
+                            window.location.reload();
+                        }
+                    });
+                });
+            }
+        });
+
+        // 启用、禁用随机订阅
+        $('#rand_subscribe').on({
+            'switchChange.bootstrapSwitch': function(event, state) {
+                var rand_subscribe = state ? 1 : 0;
+
+                $.post("{{url('admin/setConfig')}}", {_token:'{{csrf_token()}}', name:'rand_subscribe', value:rand_subscribe}, function (ret) {
+                    layer.msg(ret.message, {time:1000}, function() {
+                        if (ret.status == 'fail') {
+                            window.location.reload();
+                        }
+                    });
+                });
+            }
+        });
+
         // 启用、禁用PushBear
         $('#is_push_bear').on({
             'switchChange.bootstrapSwitch': function(event, state) {

+ 2 - 0
sql/db.sql

@@ -359,6 +359,8 @@ INSERT INTO `config` VALUES ('69', 'is_forbid_china', 0);
 INSERT INTO `config` VALUES ('70', 'is_forbid_oversea', 0);
 INSERT INTO `config` VALUES ('71', 'is_verify_register', 0);
 INSERT INTO `config` VALUES ('72', 'node_daily_report', 0);
+INSERT INTO `config` values ('73', 'mix_subscribe', 0);
+INSERT INTO `config` values ('74', 'rand_subscribe', 0);
 
 
 -- ----------------------------

+ 5 - 0
sql/update/20181204.sql

@@ -0,0 +1,5 @@
+-- 混合订阅
+INSERT INTO `config` values ('73', 'mix_subscribe', 0);
+
+-- 随机订阅
+INSERT INTO `config` values ('74', 'rand_subscribe', 0);