<?php
$title='分站信息配置';
include __DIR__ . '/head.php';
?>


<div class="p-4 md:p-6">
    <div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
        <div class="p-4 md:p-6 border-b border-gray-200">
            <h2 class="text-base md:text-lg font-semibold text-gray-800">分站信息配置</h2>
        </div>
        <div class="p-4 md:p-6">
            <form onsubmit="saveSetting(this);return false;" method="post" class="space-y-6">
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <label class="text-xs md:text-sm font-medium text-gray-700 pt-2">分站可选择域名</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-3 md:px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm" name="fenzhan_domain" value="<?php echo $conf['fenzhan_domain']?>">
                        <p class="mt-1 text-xs text-gray-500">多个域名用,隔开！</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <label class="text-xs md:text-sm font-medium text-gray-700 pt-2">主站预留域名</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-3 md:px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm" name="fenzhan_remain" value="<?php echo $conf['fenzhan_remain']?>">
                        <p class="mt-1 text-sm text-gray-900"><b><?php echo $parts['host']?></b><span class="text-red-500">，此域名必须绑定(不然无法访问)<br>主站预留域名无法被分站绑定，多个域名用,隔开！</span></p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <label class="text-xs md:text-sm font-medium text-gray-700 pt-2">未绑定域名显示404页面</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-3 md:px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm" name="fenzhan_page" default="<?php echo $conf['fenzhan_page']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <label class="text-xs md:text-sm font-medium text-gray-700 pt-2">分站域名可绑定数量</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-3 md:px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm" name="fenzhan_domain_num" default="<?php echo $conf['fenzhan_domain_num']?>">
                            <option value="0">1个</option>
                            <option value="2">2个</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <div class="md:col-start-2 md:col-span-3 space-y-4">
                        <button type="submit" class="inline-flex items-center px-6 py-2.5 bg-blue-500 text-white text-sm font-medium rounded-lg hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
                            <i class="fas fa-save mr-2"></i>保存
                        </button>
                        <div class="p-4 bg-red-50 border border-red-200 rounded-lg">
                            <p class="text-sm text-red-600">
                                <i class="fas fa-exclamation-triangle mr-2"></i>注意：用户等级大于1，才可以使用分站的功能<br>
                                分站域名不检测授权，可以随便绑定<br><br>
                                分站域名需要泛解析的：<a href="https://docs.qq.com/aio/DV3JXcVJPb0FjWFFq?u=097eef1a27014eac9627650568b2e4b1&p=BrhL0FC43KNlcfe6quJ48w" target="_blank" class="text-blue-600 hover:underline">点我查看教程</a>
                            </p>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<?php include 'foot.php'; ?>
<script type="text/javascript">
	function saveSetting(obj){
		showLoading();
		$.ajax({
			type : 'POST',
			url : 'ajax.php?act=set',
			data : $(obj).serialize(),
			dataType : 'json',
			success : function(data) {
				hideLoading();
				showToast(data.msg, 'success');
				setTimeout(function() {
					location.reload();
				}, 1000);
			},
			error:function(data){
				hideLoading();
				showToast('服务器错误', 'error');
				return false;
			}
		});
	}
	var items = $("select[default]");
	for (i = 0; i < items.length; i++) {
		$(items[i]).val($(items[i]).attr("default")||0);
	}
</script>