<?php
$title='平台安全配置';
include __DIR__ . '/head.php';
?>

<div class="p-6">
    <div class="bg-white rounded-xl shadow-sm border border-gray-200">
        <div class="p-6 border-b border-gray-200">
            <h2 class="text-lg font-semibold text-gray-800">平台安全配置</h2>
        </div>
        <div class="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="admin_user" value="<?php echo $conf['admin_user']?>">
                    </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="password" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="oldpwd" 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">
                        <input type="password" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="newpwd" 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">
                        <input type="password" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" name="newpwd2" placeholder="不修改请留空">
                    </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='account.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=account',
			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;
			}
		});
	}
</script>
