<?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-center">
                    <label class="text-sm font-medium text-gray-700">主站域名</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="localurl" value="<?php echo htmlspecialchars($conf['localurl'] ?? '', ENT_QUOTES, 'UTF-8'); ?>" placeholder="例如: www.abc.com">
                        <p class="mt-1 text-xs text-gray-500">用于监控、计划任务等无法获取当前域名时拼接链接，不要带 http(s):// 协议头和结尾的 /</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">网站名称</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="sitename" value="<?php echo $conf['sitename']?>">
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-xs md:text-sm font-medium text-gray-700">网站Logo</label>
                    <div class="md:col-span-3">
                        <div class="flex items-center gap-3 overflow-hidden">
                            <div id="logoPreview" class="w-10 h-10 rounded-lg bg-gray-100 flex items-center justify-center overflow-hidden border border-gray-200 shrink-0">
                                <?php if(!empty($conf['site_logo'])): ?>
                                <img src="<?php echo htmlspecialchars($conf['site_logo']); ?>" class="w-full h-full object-cover" alt="Logo">
                                <?php else: ?>
                                <i class="fas fa-image text-gray-400"></i>
                                <?php endif; ?>
                            </div>
                            <input type="text" class="flex-1 min-w-0 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="site_logo" id="site_logo" value="<?php echo $conf['site_logo'] ?? ''?>" placeholder="输入Logo图片URL或上传">
                            <label class="px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-lg cursor-pointer transition whitespace-nowrap shrink-0">
                                <i class="fas fa-upload mr-1"></i>上传
                                <input type="file" id="logoUpload" accept="image/*" class="hidden" onchange="uploadLogo(this)">
                            </label>
                        </div>
                        <p class="mt-1 text-xs text-gray-500">推荐尺寸：40x40像素，支持jpg/png/gif/svg格式，留空则显示默认图标</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-xs md:text-sm font-medium text-gray-700">标题栏后缀</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="title" value="<?php echo $conf['title']?>">
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-xs md:text-sm font-medium text-gray-700">关键字</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="keywords" value="<?php echo $conf['keywords']?>">
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">网站描述</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="description" value="<?php echo $conf['description']?>">
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">api接口key</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="admin_key" value="<?php echo htmlspecialchars($conf['admin_key'] ?? '', ENT_QUOTES, 'UTF-8'); ?>" placeholder="自行定义如字母、数字的组合">
                        <p class="mt-1 text-xs text-red-500">开发文档：https://www.showdoc.com.cn/2598836311330364<br>越长越好30-60个字符左右吧，用于网站api接口验证（留空则关闭）</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">SQL操作密匙</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent font-mono text-sm" name="sqlkey" value="<?php echo htmlspecialchars($conf['sqlkey'] ?? '', ENT_QUOTES, 'UTF-8'); ?>" placeholder="字段名 sqlkey，专用于 api/sql.php">
                        <p class="mt-1 text-xs text-amber-700"><code class="bg-amber-50 px-1 rounded">api/sql.php</code> 仅 <strong>POST</strong>：<code class="bg-amber-50 px-1">sqlkey</code>、<code class="bg-amber-50 px-1">sql</code>。可用表单字段，也可用 <strong>JSON</strong> 请求体（建议 <code class="bg-amber-50 px-1">Content-Type: application/json</code>）。查询返回 <code class="bg-amber-50 px-1">data</code> 行数组。<strong>留空 sqlkey 则关闭接口</strong>。</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">隐藏_接口分类商品</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="show_apiclass" default="<?php echo $conf['show_apiclass']?>">
                            <option value="0">显示</option>
                            <option value="1">隐藏</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">隐藏_等级分类商品</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="show_grade" default="<?php echo $conf['show_grade']?>">
                            <option value="0">显示</option>
                            <option value="1">隐藏</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">隐藏_全部接口分类商品</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="show_all_goods" default="<?php echo $conf['show_all_goods']?>">
                            <option value="0">隐藏</option>
                            <option value="1">显示</option>
                        </select>
                        <p class="mt-1 text-xs text-red-500">前台-购买页-商品分类-是否显示【全部接口】</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">是否显示免费接口</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="show_free_login" default="<?php echo $conf['show_free_login']?>">
                            <option value="0">不显示</option>
                            <option value="1">显示</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">初始赠送余额</label>
                    <div class="md:col-span-3">
                        <input type="number" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="user_free" value="<?php echo $conf['user_free']?>" placeholder="默认不赠送">
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">卡密功能</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="kami_open" default="<?php echo $conf['kami_open']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">卡密上级提成</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="kami_tc" default="<?php echo $conf['kami_tc']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-red-600">QQ号时长 续费方式</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="buy_type" default="<?php echo $conf['buy_type']?>">
                            <option value="0">默认</option>
                            <option value="1">仅允许卡密续费时长</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-red-600">平台账号 注册方式</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="reg_type" default="<?php echo $conf['reg_type']?>">
                            <option value="0">默认</option>
                            <option value="1">仅允许卡密 注册平台账号</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-red-600">佣金转余额</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="tc_to_rmb" default="<?php echo $conf['tc_to_rmb']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">Q Q账号</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="qq" value="<?php echo $conf['qq']?>">
                        <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-center">
                    <label class="text-sm font-medium text-gray-700">微信客服</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="kf_wx" value="<?php echo $conf['kf_wx']?>">
                        <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-center">
                    <label class="text-sm font-medium text-gray-700">售后群链接</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="shouhou_qun" value="<?php echo $conf['shouhou_qun']??''?>" placeholder="QQ群加群链接，留空则不显示左侧按钮">
                        <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-center">
                    <label class="text-sm font-medium text-gray-700">显示免费试用提示</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="show_free" default="<?php echo $conf['show_free']?>">
                            <option value="0">不显示</option>
                            <option value="1">显示</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">用户注册</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="user_open" default="<?php echo $conf['user_open']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">注册IP限制</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="user_reg_ip" default="<?php echo $conf['user_reg_ip']?>">
                            <option value="0">关闭</option>
                            <option value="1">一ip一账号</option>
                            <option value="2">同ip2分钟内不可注册</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">注册图形验证</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="regcode" default="<?php echo $conf['regcode']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">注册短信验证</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="regphonecode" default="<?php echo $conf['regphonecode']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                        <p class="mt-1 text-xs text-red-500">不会配置手机短信的别开启</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">注册邮箱验证</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="reg_email_open" default="<?php echo $conf['reg_email_open']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                        <p class="mt-1 text-xs text-red-500">开启的话，需要关闭【注册短信验证】</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">时长转移</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="is_time_shift" default="<?php echo $conf['is_time_shift']?>">
                            <option value="0">不可转移</option>
                            <option value="1">可转移</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">说说接口</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="ssapi_open" default="<?php echo $conf['ssapi_open']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                        <p class="mt-1 text-xs text-red-500">给用户提供说说接口api</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">手机QQ微信打开网站跳转浏览器</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="qqjump" default="<?php echo $conf['qqjump']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">QQ黑名单</label>
                    <div class="md:col-span-3">
                        <textarea class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="blacklist" rows="2" placeholder="多个账号之间用-隔开，如123-456"><?php echo $conf['blacklist']?></textarea>
                        <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-center">
                    <label class="text-sm font-medium text-gray-700">邀请链接</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="open_invite" default="<?php echo $conf['open_invite']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                        <p class="mt-1 text-xs text-red-500">【初始用户等级】需要设为2，建议使用分站的方式拉推广</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">统计代码</label>
                    <div class="md:col-span-3">
                        <textarea class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="tongji_code" rows="3" placeholder="建议使用百度统计，无需统计的忽略本项"><?php echo $conf['tongji_code']?></textarea>
                        <p class="mt-1 text-xs text-gray-500">百度统计:<a href="https://tongji.baidu.com/" target="_blank" class="text-blue-600 hover:text-blue-700">https://tongji.baidu.com/</a>，可知道有多少人访问过网站<br>如果保存失败，是网站服务器拦截了统计代码，放行即可！</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">页面底部信息</label>
                    <div class="md:col-span-3">
                        <textarea class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="footinfo" rows="2" placeholder="可放些备案信息"><?php echo $conf['footinfo']?></textarea>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">App下载链接</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="app_download_url" value="<?php echo $conf['app_download_url'] ?? ''?>" placeholder="填写下载地址，不填则前台不显示App下载按钮">
                        <p class="mt-1 text-xs text-gray-500">例如：https://example.com/app.apk</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">App按钮名称</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="app_download_name" value="<?php echo $conf['app_download_name'] ?? ''?>" placeholder="如：下载App（留空则默认显示“下载App”）">
                    </div>
                </div>
                <div class="border-t border-gray-200 pt-4 mt-2">
                    <h3 class="text-sm font-semibold text-gray-700 mb-3"><i class="fas fa-tags text-indigo-500 mr-2"></i>版本名称配置</h3>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">云端版名称</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="version_name_cloud" value="<?php echo $conf['version_name_cloud'] ?? '云端版'?>" placeholder="云端版">
                        <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-center">
                    <label class="text-sm font-medium text-gray-700">秒赞版名称</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="version_name_qzone" value="<?php echo $conf['version_name_qzone'] ?? '秒赞版'?>" placeholder="秒赞版">
                        <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-center">
                    <label class="text-sm font-medium text-gray-700">代挂版名称</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="version_name_dg" value="<?php echo $conf['version_name_dg'] ?? '代挂版'?>" placeholder="代挂版">
                        <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-center">
                    <label class="text-sm font-medium text-gray-700">云端·秒赞名称</label>
                    <div class="md:col-span-3">
                        <?php
                        $cloud_all_default = (preg_replace('/版$/u', '', $conf['version_name_cloud'] ?? '云端版')) . '·秒赞';
                        $version_name_cloud_all = $conf['version_name_cloud_all'] ?? $cloud_all_default;
                        ?>
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="version_name_cloud_all" value="<?php echo htmlspecialchars($version_name_cloud_all); ?>" placeholder="<?php echo htmlspecialchars($cloud_all_default); ?>">
                        <p class="mt-1 text-xs text-gray-500">默认：<?php echo htmlspecialchars($cloud_all_default); ?></p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">代挂·秒赞名称</label>
                    <div class="md:col-span-3">
                        <?php
                        $dg_all_default = (preg_replace('/版$/u', '', $conf['version_name_dg'] ?? '代挂版')) . '·秒赞';
                        $version_name_dg_all = $conf['version_name_dg_all'] ?? $dg_all_default;
                        ?>
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="version_name_dg_all" value="<?php echo htmlspecialchars($version_name_dg_all); ?>" placeholder="<?php echo htmlspecialchars($dg_all_default); ?>">
                        <p class="mt-1 text-xs text-gray-500">默认：<?php echo htmlspecialchars($dg_all_default); ?></p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-center">
                    <label class="text-sm font-medium text-gray-700">三版通用名称</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="version_name_tri_all" value="<?php echo htmlspecialchars($conf['version_name_tri_all'] ?? '三版通用'); ?>" placeholder="三版通用">
                        <p class="mt-1 text-xs text-gray-500">默认：三版通用</p>
                    </div>
                </div>
                <div class="flex items-center gap-4 pt-4">
                    <button type="submit" class="px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition">
                        <i class="fas fa-save mr-2"></i>保存
                    </button>
                    <button type="button" class="px-6 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium rounded-lg transition" onclick="if(document.referrer){history.back()}else{location.href='site.php'}">
                        <i class="fas fa-arrow-left mr-2"></i>返回
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>

        <script src="../assets/js/jquery.min.js"></script>
        <script src="../assets/js/bootstrap.min.js"></script>
<?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, data.code == 1 ? 'success' : 'error');
				if(data.code==1){
					setTimeout(function(){
						location.reload();
					}, 1000);
				}
			},
			error:function(data){
			hideLoading();
			showToast('服务器错误', 'error');
			return false;
		}
	});
	}
	
	// 上传Logo
	function uploadLogo(input) {
		if (input.files && input.files[0]) {
			var file = input.files[0];
			var maxSize = 2 * 1024 * 1024; // 2MB
			
			if (file.size > maxSize) {
				showToast('图片大小不能超过 2MB', 'error');
				return;
			}
			
			var formData = new FormData();
			formData.append('file', file);
			
			showLoading();
			$.ajax({
				url: 'ajax.php?act=upload_logo',
				type: 'POST',
				data: formData,
				processData: false,
				contentType: false,
				dataType: 'json',
				success: function(data) {
					hideLoading();
					if (data.code == 1) {
						$('#site_logo').val(data.url);
						$('#logoPreview').html('<img src="' + data.url + '" class="w-full h-full object-cover" alt="Logo">');
						showToast('上传成功', 'success');
					} else {
						showToast(data.msg || '上传失败', 'error');
					}
				},
				error: function() {
					hideLoading();
					showToast('服务器错误', 'error');
				}
			});
		}
		input.value = ''; // 清空input，允许重复选择同一文件
	}
	
	var items = $("select[default]");
	for (i = 0; i < items.length; i++) {
		$(items[i]).val($(items[i]).attr("default")||0);
	}
</script>
