1/3 宽度 → 自动删除(无确认) // ✅ 删除后立即上移 // ✅ 重置 = 删除缓存 + 重新拉取 // ✅ 保存后自动刷新 // ✅ 来源:天机阁 // ✅ 时间:北京时间(东八区) header('Content-Type: text/html; charset=utf-8'); // ========== 处理 ?reset=1 ========== if (isset($_GET['reset']) && $_GET['reset'] === '1') { @unlink(__DIR__ . '/cache/niu.json'); header('Location: ' . strtok($_SERVER['REQUEST_URI'], '?')); exit; } // ========== 配置 ========== $urls = [ "https://9280.kstore.vip/newwex.json", ]; $cache_file = __DIR__ . '/cache/niu.json'; $cache_ttl = 300; // 创建缓存目录 if (!is_dir(dirname($cache_file))) { @mkdir(dirname($cache_file), 0755, true); } // ========== 辅助函数 ========== function fetch_json($url) { $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => trim($url), CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 5, CURLOPT_CONNECTTIMEOUT => 1.5, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_USERAGENT => 'okhttp/3.15', ]); $data = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($code >= 200 && $code < 400 && $data) { $json = json_decode($data, true); if (json_last_error() === JSON_ERROR_NONE && !empty($json['sites'])) { return $json; } } return null; } function get_sites_data() { global $urls, $cache_file, $cache_ttl; if (file_exists($cache_file) && (time() - filemtime($cache_file)) <= $cache_ttl) { $data = json_decode(file_get_contents($cache_file), true); if (json_last_error() === JSON_ERROR_NONE && !empty($data['sites'])) { return $data; } } foreach ($urls as $i => $url) { if ($data = fetch_json($url)) { $data['_source'] = '天机阁'; $data['_fetched_at'] = date('Y-m-d H:i:s'); file_put_contents($cache_file, json_encode($data, JSON_UNESCAPED_UNICODE)); return $data; } } return ['sites' => [], '_source' => '天机阁', '_fetched_at' => date('Y-m-d H:i:s')]; } // ========== UA 检测:TVBox 直接返回 JSON ========== $ua = $_SERVER['HTTP_USER_AGENT'] ?? ''; if (stripos($ua, 'okhttp') !== false || stripos($ua, 'TVBox') !== false || stripos($ua, 'FongMi') !== false) { $data = get_sites_data(); header('Content-Type: application/json; charset=utf-8'); header('Access-Control-Allow-Origin: *'); echo json_encode($data, JSON_UNESCAPED_UNICODE); exit; } // ========== 保存处理 ========== if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'save') { $order = json_decode($_POST['order'], true); $all_sites = json_decode($_POST['all_sites'], true); if (!$order || !$all_sites) { http_response_code(400); echo json_encode(['success' => false, 'message' => '❌ 数据格式错误']); exit; } $new_sites = []; foreach ($order as $key) { if (isset($all_sites[$key])) { $new_sites[] = $all_sites[$key]; } } $original_data = get_sites_data(); $output = array_merge($original_data, [ 'sites' => $new_sites, '_custom_sorted' => true, '_sorted_at' => date('Y-m-d H:i:s'), '_source' => '天机阁' ]); if (file_put_contents($cache_file, json_encode($output, JSON_UNESCAPED_UNICODE)) !== false) { echo json_encode(['success' => true, 'message' => '✅ 保存成功!' . count($new_sites) . '个站点已更新']); } else { http_response_code(500); echo json_encode(['success' => false, 'message' => '❌ 保存失败!检查 cache 目录权限']); } exit; } // 获取数据 $data = get_sites_data(); $sites = $data['sites'] ?? []; $source_info = $data['_source'] ?? '天机阁'; $fetched_at = $data['_fetched_at'] ?? date('Y-m-d H:i:s'); $sites_map = []; foreach ($sites as $site) { $key = $site['key'] ?? md5(json_encode($site)); $sites_map[$key] = $site; } ?> 📺 TVBox 站点排序删除管理

📺 TVBox站点排序删除管理

📍 来源:
📊
↑ 拖拽排序左滑删除 () URL#1 → URL#2
📭
暂无站点数据
点击【重置】获取最新数据
×