<?php
require_once 'config.php';

$announcement = getEncryptAnnouncement();
$packages = getEncryptPackages();
$price = !empty($packages) ? $packages[0]['price'] : 3.00;$user = getEncryptUser();
$has_permission = $user ? hasEncryptPermission($user) : false;
?>
<?php include 'header.php'; ?>
<div class="encrypt-container">
    <div style="text-align: center; margin-bottom: 50px;">
        <h1 style="font-size: 48px; background: linear-gradient(135deg, #667eea, #764ba2); background-clip: text; -webkit-background-clip: text; color: transparent;">PHP文件加密工具</h1>
        <p style="color: var(--text-secondary); margin-top: 10px;">保护您的源代码，防止泄露与盗用</p>
    </div>
    
    <?php 
$announcement = getEncryptAnnouncement();
$announcement_enabled = getSiteConfig('encrypt_announcement_enabled') == '1';
?>

<!-- 公告区域 -->
<?php if ($announcement_enabled && !empty($announcement)): ?>
    <div class="announcement-box" style="background: linear-gradient(135deg, #fef3c7, #fde68a); padding: 20px; border-radius: 16px; margin-bottom: 40px; border-left: 5px solid #f59e0b;">
        <?php echo $announcement; ?>
    </div>
<?php endif; ?>
    
    <div class="features-grid" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 30px; margin-bottom: 50px;">
        <div class="feature" style="background: var(--bg-primary); border-radius: 20px; padding: 30px; text-align: center; border: 1px solid var(--border-color);">
            <div style="font-size: 48px;">🔒</div>
            <h3>代码混淆</h3>
            <p>变量名随机化，增加阅读难度</p>
        </div>
        <div class="feature" style="background: var(--bg-primary); border-radius: 20px; padding: 30px; text-align: center; border: 1px solid var(--border-color);">
            <div style="font-size: 48px;">📦</div>
            <h3>Gzip压缩</h3>
            <p>减小文件体积，提升加载速度</p>
        </div>
        <div class="feature" style="background: var(--bg-primary); border-radius: 20px; padding: 30px; text-align: center; border: 1px solid var(--border-color);">
            <div style="font-size: 48px;">⚡</div>
            <h3>高性能</h3>
            <p>加密后性能损失极小</p>
        </div>
        <div class="feature" style="background: var(--bg-primary); border-radius: 20px; padding: 30px; text-align: center; border: 1px solid var(--border-color);">
            <div style="font-size: 48px;">🛡️</div>
            <h3>安全保护</h3>
            <p>防止源码泄露</p>
        </div>
    </div>
    
    <?php if ($has_permission): ?>
        <div style="text-align: center;">
            <a href="/encrypt/encrypt.php" class="btn btn-primary" style="padding: 14px 40px; font-size: 18px;">立即加密文件</a>
        </div>
    <?php else: ?>
        <div class="price-card" style="max-width: 400px; margin: 0 auto; background: var(--bg-primary); border-radius: 24px; padding: 30px; text-align: center; border: 2px solid var(--primary-color);">
            <h2>加密服务</h2>
            <div style="font-size: 48px; color: var(--primary-color); margin: 20px 0;">¥<?php echo number_format($price, 2); ?></div>
            <p>永久有效，不限次数</p>
            <p style="margin: 20px 0; color: var(--text-secondary);">管理员和代理商免费使用</p>
            <a href="/encrypt/buy.php" class="btn btn-primary" style="padding: 12px 30px;">立即购买</a>
        </div>
    <?php endif; ?>
</div>
<?php include 'footer.php'; ?>