<?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">QQ登陆页面公告</label>
                    <div class="md:col-span-3">
                        <textarea 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="loginmsg" id="editor_loginmsg" rows="4"><?php echo $conf['loginmsg']?></textarea>
                    </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="loginmsg_place" default="<?php echo $conf['loginmsg_place']?>">
                            <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">
                        <textarea 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="anounce" id="editor_anounce" rows="4"><?php echo $conf['anounce']?></textarea>
                    </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">
                        <textarea 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="anounce_user" id="editor_anounce_user" rows="4"><?php echo $conf['anounce_user']?></textarea>
                    </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">
                        <textarea 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="anounce_alert" id="editor_anounce_alert" rows="4"><?php echo $conf['anounce_alert']?></textarea>
                    </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">
                        <textarea 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="anounce_alert_all" id="editor_anounce_alert_all" rows="4"><?php echo $conf['anounce_alert_all']?></textarea>
                    </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="anounce_alert_freq" default="<?php echo $conf['anounce_alert_freq'] ?? '0'; ?>">
                            <option value="0">每次访问都显示</option>
                            <option value="1">一天显示一次</option>
                        </select>
                        <p class="text-xs text-gray-500 mt-1">选择弹窗公告的显示频率</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">
                        <textarea 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="reg_gg" id="editor_reg_gg" rows="4"><?php echo $conf['reg_gg']?></textarea>
                    </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="reg_clause_open" default="<?php echo $conf['reg_clause_open'] ?? '1'; ?>">
                            <option value="1">开启</option>
                            <option value="2">开启_阅读5秒</option>
                            <option value="0">关闭</option>
                        </select>
                        <p class="text-xs text-gray-500 mt-1">开启后注册前需要阅读并同意条款，开启_阅读5秒需要等待5秒倒计时</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">
                        <textarea 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="reg_clause_content" id="editor_reg_clause" rows="6"><?php 
$default_clause = 'QQ账号授权使用免责条款
用户自愿授权本平台使用其登录的QQ账号（以下称：账号），平台可在服务范围内对该账号执行登录、读取信息、点赞、评论、发送消息、互动操作等相关功能，包括但不限于上述行为。

用户承诺：
1. 授权账号为本人合法持有，确保账号使用符合法律法规及QQ平台规则。
2. 不利用授权功能从事任何违法违规、侵权、骚扰、诈骗等不正当行为。
3. 因用户使用行为、账号安全、违规操作等产生的一切法律责任与后果，由用户自行承担，本平台不承担任何责任。
4. 若用户行为给平台或第三方造成损失，用户应全额赔偿。

本平台仅按授权提供技术服务，不对账号操作的法律风险、账号安全、内容合规性承担责任。';
echo $conf['reg_clause_content'] ?? $default_clause; 
?></textarea>
                        <p class="text-xs text-gray-500 mt-1">自定义注册时需要阅读的条款内容</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">
                        <textarea 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="tixian_gg" id="editor_tixian_gg" rows="4"><?php echo $conf['tixian_gg']?></textarea>
                    </div>
                </div>
                <div class="border-t border-gray-200 pt-4 mt-4">
                    <h3 class="text-sm font-semibold text-gray-800 mb-4"><i class="fas fa-shopping-bag text-indigo-500 mr-2"></i>购买页活动公告</h3>
                </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">
                        <textarea 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="shop_activity_notice" id="editor_shop_activity" rows="4"><?php echo $conf['shop_activity_notice'] ?? ''?></textarea>
                        <p class="text-xs text-gray-500 mt-1">在购买页顶部显示的活动公告，支持富文本</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">
                        <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="shop_activity_show" default="<?php echo $conf['shop_activity_show'] ?? '0'; ?>">
                            <option value="0">不显示</option>
                            <option value="1">显示</option>
                        </select>
                        <p class="text-xs text-gray-500 mt-1">开启后将在购买页顶部显示活动公告</p>
                    </div>
                </div>
                <div class="border-t border-gray-200 pt-4 mt-4">
                    <h3 class="text-sm font-semibold text-gray-800 mb-4"><i class="fas fa-comment-dots text-indigo-500 mr-2"></i>账号管理页面文案</h3>
                </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">
                        <textarea 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="qqlist_cloud_subtitle" rows="2"><?php echo $conf['qqlist_cloud_subtitle'] ?? '云端，群管，娱乐，抢包等等功能'?></textarea>
                        <p class="text-xs text-gray-500 mt-1">显示在“云端账号管理”标题下方</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">
                        <textarea 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="qqlist_dg_subtitle" rows="2"><?php echo $conf['qqlist_dg_subtitle'] ?? '等级加速自动做任务让你账号快速升级'?></textarea>
                        <p class="text-xs text-gray-500 mt-1">显示在“代挂账号管理”标题下方</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">
                        <textarea 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="qzone_manage_subtitle" rows="2"><?php echo $conf['qzone_manage_subtitle'] ?? '自动点赞、评论、签到、发说说，管理秒赞账号状态'?></textarea>
                        <p class="text-xs text-gray-500 mt-1">显示在“空间秒赞管理”标题下方</p>
                    </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">
                        <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>
                </div>
            </form>
        </div>
    </div>
</div>

<?php include 'foot.php'; ?>
<script src="../assets/kindeditor/kindeditor-all-min.js"></script>
<script src="../assets/kindeditor/zh-CN.js"></script>
<script type="text/javascript">
	var gonggaoEditors = [];
	function saveSetting(obj){
		gonggaoEditors.forEach(function(ed) {
			if (ed && typeof ed.sync === 'function') ed.sync();
		});
		showLoading();
		$.ajax({
			type : 'POST',
			url : 'ajax.php?act=set',
			data : $(obj).serialize(),
			dataType : 'json',
			success : function(data) {
				hideLoading();
				showToast(data.msg, 'success');
				location.reload();
			},
			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);
	}
	function isMobileEditor() {
		return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || (window.innerWidth > 0 && window.innerWidth < 768);
	}
	if (!isMobileEditor()) {
		KindEditor.ready(function(K) {
			var ids = ['editor_loginmsg', 'editor_anounce', 'editor_anounce_user', 'editor_anounce_alert', 'editor_anounce_alert_all', 'editor_reg_gg', 'editor_reg_clause', 'editor_tixian_gg', 'editor_shop_activity'];
			var opts = {
				resizeType: 1,
				allowUpload: false,
				allowPreviewEmoticons: false,
				uploadJson: './ajax.php?act=article_upload',
				items: ['fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'removeformat', 'formatblock', 'hr', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'image', 'link', 'unlink', 'code', '|', 'fullscreen', 'source', 'preview']
			};
			ids.forEach(function(id) {
				var el = document.getElementById(id);
				if (el) gonggaoEditors.push(K.create('#' + id, opts));
			});
		});
	}
</script>
