// ===== УЛУЧШЕННАЯ СИСТЕМА ЗАКАЗА РЕКЛАМЫ ===== // Проверка лимитов URL function canSendAsUrl(text) { const MAX_SAFE_URL_LENGTH = 1900; const encodedLength = encodeURIComponent(text).length; const fullUrlLength = 'https://t.me/oleg777555?text='.length + encodedLength; console.log('Проверка лимитов URL:', { textLength: text.length, encodedLength: encodedLength, fullUrlLength: fullUrlLength, canSend: fullUrlLength <= MAX_SAFE_URL_LENGTH }); return fullUrlLength <= MAX_SAFE_URL_LENGTH; } function splitOrderIntoTelegramMessages(fullText) { const MAX_TELEGRAM_LENGTH = 4096; const MAX_URL_LENGTH = 1900; // Безопасный лимит для URL const parts = []; // Проверяем, помещается ли в одно сообщение И в URL if (fullText.length <= MAX_TELEGRAM_LENGTH) { const encodedLength = encodeURIComponent(fullText).length; if (encodedLength <= MAX_URL_LENGTH) { return [fullText]; } } const sections = fullText.split('\n\n'); let currentPart = ''; let partNumber = 1; for (let i = 0; i < sections.length; i++) { const section = sections[i]; const testPart = currentPart + (currentPart ? '\n\n' : '') + section; const encodedTestLength = encodeURIComponent(testPart).length; // Проверяем оба лимита if (testPart.length > MAX_TELEGRAM_LENGTH - 100 || encodedTestLength > MAX_URL_LENGTH) { if (currentPart) { const partHeader = `🎯 ЗАЯВКА НА РЕКЛАМУ (Часть ${partNumber})\n\n`; parts.push(partHeader + currentPart); partNumber++; currentPart = ''; } } const encodedSectionLength = encodeURIComponent(section).length; if (section.length > MAX_TELEGRAM_LENGTH - 200 || encodedSectionLength > MAX_URL_LENGTH - 200) { if (section.includes('📋 СПИСОК ПЛОЩАДОК:')) { const channelParts = splitChannelsListWithUrlLimits(section); channelParts.forEach((channelPart) => { const partHeader = `🎯 ЗАЯВКА НА РЕКЛАМУ (Часть ${partNumber})\n\n`; parts.push(partHeader + channelPart); partNumber++; }); } else { currentPart += (currentPart ? '\n\n' : '') + section; } } else { currentPart += (currentPart ? '\n\n' : '') + section; } } if (currentPart) { const partHeader = `🎯 ЗАЯВКА НА РЕКЛАМУ (Часть ${partNumber})\n\n`; parts.push(partHeader + currentPart); } return parts; } function splitChannelsListWithUrlLimits(channelsSection) { const MAX_PART_LENGTH = 2500; const MAX_URL_ENCODED_LENGTH = 1500; const lines = channelsSection.split('\n'); const parts = []; let currentPart = ''; let channelsInPart = 0; for (let i = 0; i < lines.length; i++) { const line = lines[i]; if (line.match(/^\d+\./)) { const nextChannelLines = []; for (let j = i; j < lines.length && j < i + 3; j++) { nextChannelLines.push(lines[j]); if (j > i && lines[j + 1] && lines[j + 1].match(/^\d+\./)) break; } const nextChannelText = nextChannelLines.join('\n'); const testPart = currentPart + '\n' + nextChannelText; const encodedTestLength = encodeURIComponent(testPart).length; if ((testPart.length > MAX_PART_LENGTH || encodedTestLength > MAX_URL_ENCODED_LENGTH) && channelsInPart > 0) { const partHeader = `📋 СПИСОК ПЛОЩАДОК (продолжение):\n\n`; parts.push(partHeader + currentPart); currentPart = ''; channelsInPart = 0; } channelsInPart++; } currentPart += (currentPart ? '\n' : '') + line; } if (currentPart) { const partHeader = channelsInPart === tableData.length ? '📋 СПИСОК ПЛОЩАДОК:\n\n' : '📋 СПИСОК ПЛОЩАДОК (продолжение):\n\n'; parts.push(partHeader + currentPart); } return parts; } // Краткая заявка для быстрой отправки function generateCompactOrderText() { const user = currentUserData.user; const username = user.username; const firstName = user.first_name || ''; const lastName = user.last_name || ''; const fullName = `${firstName} ${lastName}`.trim(); let totalSubscribers = 0; let channelsCount = 0; let groupsCount = 0; tableData.forEach(channel => { const subscribers = parseInt(channel[3]) || 0; const type = channel[2].toLowerCase(); totalSubscribers += subscribers; if (type === 'канал') channelsCount++; else if (type === 'группа' || type === 'чат') groupsCount++; }); const totalPrice = calculatePrice(totalSubscribers); const discountPercent = getDiscountPercent(totalSubscribers); let orderText = `🎯 ЗАЯВКА НА РЕКЛАМУ\n\n`; orderText += `👤 ${fullName} (@${username})\n\n`; orderText += `📊 ${tableData.length} площадок | ${numberWithSpaces(totalSubscribers)} подписчиков\n`; orderText += `├─ Каналов: ${channelsCount}\n`; orderText += `└─ Групп: ${groupsCount}\n\n`; if (discountPercent > 0) { orderText += `💰 ${numberWithSpaces(totalPrice)} ₽ (скидка ${discountPercent}%)\n\n`; } else { orderText += `💰 ${numberWithSpaces(totalPrice)} ₽\n\n`; } // Добавляем только топ-3 канала const sortedChannels = [...tableData].sort((a, b) => (parseInt(b[3]) || 0) - (parseInt(a[3]) || 0)); const topChannels = sortedChannels.slice(0, 3); orderText += `🔝 ТОП-3 КАНАЛА:\n`; topChannels.forEach((channel, index) => { const name = channel[1].length > 20 ? channel[1].substring(0, 20) + '...' : channel[1]; const subscribers = numberWithSpaces(parseInt(channel[3]) || 0); orderText += `${index + 1}. ${name} (${subscribers})\n`; }); if (tableData.length > 3) { orderText += `...и еще ${tableData.length - 3}\n`; } orderText += `\n📋 Полный список отправлю отдельно\n`; orderText += `🌐 Через https://900.su`; return orderText; } function generateFullOrderText() { const user = currentUserData.user; const username = user.username; const firstName = user.first_name || ''; const lastName = user.last_name || ''; const fullName = `${firstName} ${lastName}`.trim(); let totalSubscribers = 0; let channelsCount = 0; let groupsCount = 0; tableData.forEach(channel => { const subscribers = parseInt(channel[3]) || 0; const type = channel[2].toLowerCase(); totalSubscribers += subscribers; if (type === 'канал') channelsCount++; else if (type === 'группа' || type === 'чат') groupsCount++; }); const totalPrice = calculatePrice(totalSubscribers); const discountPercent = getDiscountPercent(totalSubscribers); // ВАЖНО: Сортируем каналы и включаем ВСЕ каналы в заявку const sortedChannels = [...tableData].sort((a, b) => (parseInt(b[3]) || 0) - (parseInt(a[3]) || 0)); let channelsList = ''; sortedChannels.forEach((channel, index) => { const url = channel[0]; const name = channel[1]; const type = channel[2]; const subscribers = parseInt(channel[3]) || 0; const price = Math.floor(subscribers * (totalPrice / totalSubscribers)); channelsList += `${index + 1}. ${name}\n`; channelsList += ` ${type} | ${numberWithSpaces(subscribers)} подписчиков | ${numberWithSpaces(price)} ₽\n`; channelsList += ` ${url}\n\n`; }); let orderText = `🎯 ЗАЯВКА НА РАЗМЕЩЕНИЕ РЕКЛАМЫ\n\n`; orderText += `👤 ЗАКАЗЧИК:\n`; orderText += `Имя: ${fullName}\n`; orderText += `Telegram: @${username}\n\n`; orderText += `📊 СТАТИСТИКА:\n`; orderText += `Всего площадок: ${tableData.length}\n`; orderText += `├─ Каналов: ${channelsCount}\n`; orderText += `└─ Групп/чатов: ${groupsCount}\n\n`; orderText += `👥 АУДИТОРИЯ:\n`; orderText += `Общий охват: ${numberWithSpaces(totalSubscribers)} подписчиков\n`; orderText += `Средний размер: ${numberWithSpaces(Math.round(totalSubscribers / tableData.length))}\n\n`; orderText += `💰 СТОИМОСТЬ:\n`; if (discountPercent > 0) { const originalPrice = totalSubscribers; const discount = originalPrice - totalPrice; orderText += `Базовая цена: ${numberWithSpaces(originalPrice)} ₽\n`; orderText += `Скидка ${discountPercent}%: -${numberWithSpaces(discount)} ₽\n`; orderText += `Итого: ${numberWithSpaces(totalPrice)} ₽\n\n`; } else { orderText += `Итого: ${numberWithSpaces(totalPrice)} ₽\n\n`; } orderText += `📋 СПИСОК ПЛОЩАДОК:\n\n${channelsList}`; orderText += `📅 Дата заявки: ${new Date().toLocaleString('ru-RU')}\n`; orderText += `🌐 Сгенерировано через https://900.su`; return orderText; } function orderAdvertising() { if (!currentUserData || !currentUserData.user || !currentUserData.user.username) { showStatus('Для заказа рекламы необходимо указать username в настройках Telegram', 'error'); return; } if (!tableData || tableData.length === 0) { showStatus('Добавьте каналы для заказа рекламы', 'error'); return; } let totalSubscribers = 0; let channelsCount = 0; let groupsCount = 0; tableData.forEach(channel => { const subscribers = parseInt(channel[3]) || 0; const type = channel[2].toLowerCase(); totalSubscribers += subscribers; if (type === 'канал') { channelsCount++; } else if (type === 'группа' || type === 'чат') { groupsCount++; } }); const totalPrice = calculatePrice(totalSubscribers); const discountPercent = getDiscountPercent(totalSubscribers); const fullOrder = generateFullOrderText(); const orderParts = splitOrderIntoTelegramMessages(fullOrder); console.log('=== DEBUG: Заявка готова ==='); console.log('Количество каналов:', tableData.length); console.log('Общий размер заявки:', fullOrder.length, 'символов'); console.log('Количество частей:', orderParts.length); console.log('Размеры частей:', orderParts.map(part => part.length)); console.log('URL лимиты:', orderParts.map(part => ({ length: part.length, encoded: encodeURIComponent(part).length, canSend: canSendAsUrl(part) }))); showImprovedOrderModal(orderParts, totalPrice, totalSubscribers, discountPercent); showStatus('Заявка подготовлена! Выберите удобный способ отправки.', 'success'); } function showImprovedOrderModal(orderParts, totalPrice, totalSubscribers, discountPercent) { const modal = document.createElement('div'); modal.style.cssText = ` position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box; `; const modalContent = document.createElement('div'); modalContent.style.cssText = ` background: white; border-radius: 10px; padding: 30px; max-width: 700px; width: 100%; max-height: 80vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.3); `; // Проверяем общий размер заявки const hasLongParts = orderParts.some(part => !canSendAsUrl(part)); modalContent.innerHTML = `

🎯 Заявка на размещение рекламы

📊 Краткая сводка:
Площадок: ${tableData.length}
Подписчиков: ${numberWithSpaces(totalSubscribers)}
Стоимость: ${numberWithSpaces(totalPrice)} ₽${discountPercent > 0 ? ` (скидка ${discountPercent}%)` : ''}
${hasLongParts ? `
⚠️ Внимание: Заявка очень большая. Некоторые части будут скопированы в буфер обмена для ручной вставки в Telegram.
` : `
🚀 Автоматическая отправка:
Заявка разбита на ${orderParts.length} ${orderParts.length === 1 ? 'сообщение' : 'сообщения'} и будет отправлена автоматически
`}

📤 Способы отправки:

📋 Предварительный просмотр (${orderParts.length} ${orderParts.length === 1 ? 'часть' : 'части'})
${orderParts.map((part, index) => { const canSend = canSendAsUrl(part); const encodedLength = encodeURIComponent(part).length; return `
Часть ${index + 1} (${part.length} символов, ${encodedLength} байт) ${canSend ? '✅' : '⚠️'} ${!canSend ? '
Будет скопирована в буфер обмена' : ''}
${part}
`; }).join('')}
💡 Как работает отправка:
1. ✅ Короткие части открываются в Telegram автоматически
2. ⚠️ Длинные части копируются в буфер обмена
3. 🔄 Система автоматически переходит к следующей части
4. 📝 Вам нужно только нажимать "Отправить" в Telegram
`; modal.appendChild(modalContent); document.body.appendChild(modal); // Обработчики событий document.getElementById('auto-send-btn').onclick = () => { startAutoSending(orderParts); }; document.getElementById('compact-send-btn').onclick = () => { const compactOrder = generateCompactOrderText(); if (canSendAsUrl(compactOrder)) { const telegramUrl = `https://t.me/oleg777555?text=${encodeURIComponent(compactOrder)}`; window.open(telegramUrl, '_blank'); showStatus('Краткая заявка отправлена! Полный список каналов отправьте отдельно.', 'success'); } else { copyToClipboard(compactOrder); window.open('https://t.me/oleg777555', '_blank'); showStatus('Краткая заявка скопирована в буфер обмена.', 'info'); } }; document.getElementById('manual-copy-btn').onclick = () => { const allText = orderParts.join('\n\n--- СЛЕДУЮЩЕЕ СООБЩЕНИЕ ---\n\n'); copyToClipboard(allText); showStatus('Все части заявки скопированы! Отправьте их @oleg777555', 'success'); }; document.getElementById('telegram-web-btn').onclick = () => { const telegramWebUrl = `https://web.telegram.org/k/#@oleg777555`; window.open(telegramWebUrl, '_blank'); copyToClipboard(orderParts.join('\n\n--- СЛЕДУЮЩЕЕ СООБЩЕНИЕ ---\n\n')); showStatus('Telegram Web открыт, заявка скопирована в буфер обмена', 'success'); }; document.getElementById('close-modal-btn').onclick = () => { document.body.removeChild(modal); }; modal.onclick = (e) => { if (e.target === modal) { document.body.removeChild(modal); } }; } function startAutoSending(orderParts) { let currentPartIndex = 0; const progressDiv = document.getElementById('sending-progress'); const currentPartSpan = document.getElementById('current-part'); const progressBar = document.getElementById('progress-bar'); progressDiv.style.display = 'block'; function sendNextPart() { if (currentPartIndex >= orderParts.length) { progressDiv.innerHTML = `
✅ Все части заявки отправлены! Спасибо за обращение.
`; showStatus('Заявка успешно отправлена администратору!', 'success'); return; } const part = orderParts[currentPartIndex]; const partNumber = currentPartIndex + 1; currentPartSpan.textContent = partNumber; const progressPercent = (partNumber / orderParts.length) * 100; progressBar.style.width = progressPercent + '%'; // Проверяем, можем ли отправить через URL if (canSendAsUrl(part)) { const telegramUrl = `https://t.me/oleg777555?text=${encodeURIComponent(part)}`; if (/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { const mobileUrl = `tg://resolve?domain=oleg777555&text=${encodeURIComponent(part)}`; window.location.href = mobileUrl; setTimeout(() => { window.open(telegramUrl, '_blank'); }, 1000); } else { window.open(telegramUrl, '_blank'); } } else { // URL слишком длинный, копируем в буфер и открываем чат copyToClipboard(part); window.open('https://t.me/oleg777555', '_blank'); showStatus(`Часть ${partNumber} скопирована в буфер обмена. Вставьте её в чат с @oleg777555`, 'info'); } currentPartIndex++; if (currentPartIndex < orderParts.length) { setTimeout(() => { if (confirm(`Отправили часть ${partNumber}? Переходим к части ${currentPartIndex + 1}?`)) { sendNextPart(); } else { progressDiv.innerHTML = ` `; } }, 4000); // Увеличиваем время ожидания } else { setTimeout(() => { progressDiv.innerHTML = `
✅ Все части заявки отправлены! Спасибо за обращение.
`; showStatus('Заявка успешно отправлена администратору!', 'success'); }, 2000); } } // Делаем функции доступными глобально window.sendNextPart = sendNextPart; window.continueAutoSending = () => { sendNextPart(); }; sendNextPart(); } // Инициализация
Warning: session_name(): Cannot change session name when headers already sent in /var/www/zebra/data/www/900.su/auth.php on line 4

Warning: session_start(): Cannot start session when headers already sent in /var/www/zebra/data/www/900.su/auth.php on line 5

Warning: Cannot modify header information - headers already sent by (output started at /var/www/zebra/data/www/900.su/index.php:1) in /var/www/zebra/data/www/900.su/auth.php on line 206