JAYNESTV commited on
Commit
9060c11
·
verified ·
1 Parent(s): 07e681d

Upload all-1.php.txt

Browse files
Files changed (1) hide show
  1. all-1.php.txt +89 -0
all-1.php.txt ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * all.php — JAYNES MAX TV (v3.3-direct)
4
+ * Inaita runBatch() moja kwa moja bila HTTP curl kwa part files.
5
+ * Hii inaepuka tatizo la timeout la v3.2-split.
6
+ */
7
+
8
+ header('Content-Type: application/json; charset=UTF-8');
9
+ header('Access-Control-Allow-Origin: *');
10
+ header('Access-Control-Allow-Methods: GET, OPTIONS');
11
+ if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(204); exit; }
12
+
13
+ @ini_set('display_errors', '0');
14
+ error_reporting(E_ERROR);
15
+
16
+ ignore_user_abort(true);
17
+ set_time_limit(300);
18
+
19
+ require __DIR__ . '/kraudius_core.php';
20
+
21
+ $t0 = microtime(true);
22
+ $source = trim($_GET['source'] ?? 'kraudius');
23
+
24
+ // Batches — zana 5 za parallel (simulated sequential)
25
+ $batches = [
26
+ [1, 11],
27
+ [12, 22],
28
+ [23, 30],
29
+ [31, 40],
30
+ [41, 52],
31
+ ];
32
+
33
+ $channels = [];
34
+ $okCount = 0;
35
+ $failCount = 0;
36
+ $fb1Count = 0;
37
+ $dupCount = 0;
38
+ $partsDebug = [];
39
+ $partsFailed = [];
40
+
41
+ foreach ($batches as $idx => [$from, $to]) {
42
+ $partName = 'part' . ($idx + 1) . '.php';
43
+ $tPart = microtime(true);
44
+
45
+ try {
46
+ // Ita runBatch() moja kwa moja — bila HTTP
47
+ $result = runBatch($from, $to, $source);
48
+
49
+ $channels = array_merge($channels, $result['channels'] ?? []);
50
+ $okCount += $result['ok_count'] ?? 0;
51
+ $failCount += $result['fail_count'] ?? 0;
52
+ $fb1Count += $result['with_fallback1'] ?? 0;
53
+ $dupCount += $result['same_url_count'] ?? 0;
54
+
55
+ $partsDebug[$partName] = [
56
+ 'ok' => true,
57
+ 'range' => "$from-$to",
58
+ 'part_ms' => (int)((microtime(true) - $tPart) * 1000),
59
+ 'elapsed_ms' => $result['elapsed_ms'] ?? null,
60
+ ];
61
+ } catch (Throwable $e) {
62
+ $partsFailed[] = $partName;
63
+ $partsDebug[$partName] = [
64
+ 'ok' => false,
65
+ 'range' => "$from-$to",
66
+ 'ms' => (int)((microtime(true) - $tPart) * 1000),
67
+ 'error' => $e->getMessage(),
68
+ ];
69
+ }
70
+ }
71
+
72
+ usort($channels, fn($a, $b) => ($a['channel'] ?? 0) <=> ($b['channel'] ?? 0));
73
+
74
+ echo json_encode([
75
+ 'success' => empty($partsFailed),
76
+ 'version' => 'v3.3-direct',
77
+ 'source' => $source === 'all' ? 'KraudiusTV + LiveBlog365' : sourceLabel($source),
78
+ 'range' => '1-52',
79
+ 'total' => count($channels),
80
+ 'ok_count' => $okCount,
81
+ 'fail_count' => $failCount,
82
+ 'with_fallback1' => $fb1Count,
83
+ 'same_url_count' => $dupCount,
84
+ 'parts_failed' => $partsFailed,
85
+ 'fetched_at' => date('Y-m-d H:i:s'),
86
+ 'elapsed_ms' => (int)((microtime(true) - $t0) * 1000),
87
+ 'parts_debug' => $partsDebug,
88
+ 'channels' => $channels,
89
+ ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);