号池源码php

https://linux.do/t/topic/158127?page=4
<?php
// 从文件中读取 session keys
$session_keys = file('session_keys.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$sk_array = array();
for ($i = 0; $i < 44; $i++) {
    $sk_array[$i] = trim(explode('=', $session_keys[$i])[1], '"');
}

function getLoginUrl($session_key) {
    $ch = curl_init('https://claude.asia/manage-api/auth/oauth_token');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
        'session_key' => $session_key,
        'unique_name' => uniqid() // 使用 uniqid() 生成唯一名称以实现会话隔离
    ]));
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
    $response = curl_exec($ch);
    curl_close($ch);
    $data = json_decode($response, true);
    
    if (isset($data['login_url'])) {
        // 确保返回完整的 URL
        if (strpos($data['login_url'], 'http') !== 0) {
            return 'https://claude.asia' . $data['login_url'];
        }
        return $data['login_url'];
    }
    
    return '#'; // 如果无法获取 login_url,返回 '#'
}

function getAccountStatus($account_number) {
    $clicks_file = "clicks_{$account_number}.txt";
    $current_time = time();
    $five_minutes_ago = $current_time - 300; // 5 minutes = 300 seconds
    
    if (file_exists($clicks_file)) {
        $clicks = file($clicks_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
        
        // Filter clicks within the last 5 minutes
        $recent_clicks = array_filter($clicks, function($click_time) use ($five_minutes_ago) {
            return $click_time > $five_minutes_ago;
        });
        
        if (count($recent_clicks) >= 1) {
            return ['color' => 'red', 'status' => '繁忙'];
        }
    }
    
    return ['color' => 'green', 'status' => '空闲'];
}

function updateClickTime($account_number) {
    $clicks_file = "clicks_{$account_number}.txt";
    $current_time = time();
    
    // Read existing clicks
    $clicks = file_exists($clicks_file) ? file($clicks_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) : [];
    
    // Add new click time
    array_push($clicks, $current_time);
    
    // Keep only the last 5 minutes of clicks
    $five_minutes_ago = $current_time - 300;
    $clicks = array_filter($clicks, function($click_time) use ($five_minutes_ago) {
        return $click_time > $five_minutes_ago;
    });
    
    // Save updated clicks
    file_put_contents($clicks_file, implode("\n", $clicks));
}

if (isset($_GET['clicked'])) {
    $clicked_account = $_GET['clicked'];
    updateClickTime($clicked_account);
    exit;
}

$login_urls = [];
$account_statuses = [];
for ($i = 1; $i <= 44; $i++) {
    $login_urls[$i] = getLoginUrl($sk_array[$i-1]);
    $account_statuses[$i] = getAccountStatus($i);
}
?>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Claude免费镜像号池</title>
    <style>
        body, html {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            padding: 0;
            min-height: 100vh;
            background: linear-gradient(135deg, #ffffff, #f0f0f0);
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px 0;
        }
        h1 {
            color: #333;
            margin: 0;
        }
        nav {
            text-align: right;
        }
        .nav-link {
            background-color: #764ba2;
            color: white;
            text-decoration: none;
            padding: 10px 20px;
            border-radius: 5px;
            transition: background-color 0.3s;
        }
        .nav-link:hover {
            background-color: #5a3a7e;
        }
        .accounts {
            display: grid;
            grid-template-columns: repeat(10, 1fr);
            gap: 10px;
            margin-top: 20px;
        }
        .account {
            background-color: #4CAF50;
            color: white;
            text-decoration: none;
            padding: 10px 5px;
            border-radius: 5px;
            text-align: center;
            font-size: 0.9rem;
            transition: transform 0.3s, background-color 0.3s;
        }
        .account:hover {
            transform: scale(1.05);
        }
        .account.red {
            background-color: #f34336;
        }
        footer {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-top: 40px;
            padding-top: 20px;
            border-top: 1px solid #ddd;
        }
        .footer-left {
            flex: 1;
        }
        .footer-right {
            display: flex;
            gap: 20px;
        }
        .qr-code {
            text-align: center;
        }
        .qr-code img {
            width: 100px;
            height: 100px;
        }
        .copyright {
            text-align: center;
            margin-top: 20px;
            font-size: 0.9rem;
            color: #666;
        }
        @media (max-width: 768px) {
            .accounts {
                grid-template-columns: repeat(3, 1fr);
            }
            footer {
                flex-direction: column;
                align-items: center;
            }
            .footer-left {
                text-align: center;
                margin-bottom: 20px;
            }
            .footer-right {
                justify-content: center;
            }
        }
    </style>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        function updateStatus(accountNumber) {
            $.get('?clicked=' + accountNumber, function() {
                location.reload();
            });
        }
    </script>
</head>
<body>
    <div class="container">
        <header>
            <img src="https://share.claude.asia/img/logo.png" height="30" alt="logo">
            <nav>
            </nav>
        </header>

        <main>
            <h2 style="text-align:center;">免费账号</h2>
            <div class="accounts">
                <?php for ($i = 1; $i <= 44; $i++): ?>
                    <a href="<?php echo htmlspecialchars($login_urls[$i]); ?>" 
                       class="account <?php echo $account_statuses[$i]['color']; ?>" 
                       target="_blank" 
                       onclick="updateStatus(<?php echo $i; ?>)">
                        账号<?php echo $i; ?><br>(<?php echo $account_statuses[$i]['status']; ?>)
                    </a>
                <?php endfor; ?>
            </div>
        </main>

        <footer>
            <div class="footer-left">
            </div>
            <div class="footer-right">
               
                </div>
            </div>
        </footer>
        <div class="copyright">
            © Claude.asia
        </div>
    </div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值