Compare commits
No commits in common. "ai-dev" and "master" have entirely different histories.
@ -1,78 +0,0 @@
|
|||||||
|
|
||||||
:root {
|
|
||||||
--bs-body-bg: #111827;
|
|
||||||
--bs-body-color: #f9fafb;
|
|
||||||
--primary-color: #9333ea;
|
|
||||||
--surface-color: #1f2937;
|
|
||||||
--border-color: #374151;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
bottom: 0;
|
|
||||||
width: 250px;
|
|
||||||
padding: 20px;
|
|
||||||
background-color: var(--surface-color);
|
|
||||||
border-right: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar .nav-link {
|
|
||||||
color: #9ca3af;
|
|
||||||
padding: 10px 15px;
|
|
||||||
border-radius: 0.375rem;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar .nav-link i {
|
|
||||||
margin-right: 10px;
|
|
||||||
width: 20px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.sidebar .nav-link:hover, .sidebar .nav-link.active {
|
|
||||||
background-color: var(--primary-color);
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar .logo {
|
|
||||||
display: block;
|
|
||||||
color: #fff;
|
|
||||||
font-size: 1.5rem;
|
|
||||||
font-weight: bold;
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.main-content {
|
|
||||||
margin-left: 250px;
|
|
||||||
padding: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
background-color: var(--surface-color);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-header {
|
|
||||||
background-color: transparent;
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.stat-card h5 {
|
|
||||||
color: #9ca3af;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stat-card .display-4 {
|
|
||||||
color: var(--primary-color);
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
document.addEventListener('DOMContentLoaded', function () {
|
|
||||||
const ctx = document.getElementById('viewsChart');
|
|
||||||
if (!ctx) return;
|
|
||||||
|
|
||||||
new Chart(ctx, {
|
|
||||||
type: 'line',
|
|
||||||
data: {
|
|
||||||
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
|
||||||
datasets: [{
|
|
||||||
label: 'Average Views',
|
|
||||||
data: [1200, 1900, 3000, 5000, 2300, 3100, 4200, 3800, 6000, 7200, 5500, 8000],
|
|
||||||
borderColor: '#9333ea',
|
|
||||||
backgroundColor: 'rgba(147, 51, 234, 0.1)',
|
|
||||||
fill: true,
|
|
||||||
tension: 0.4
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
responsive: true,
|
|
||||||
maintainAspectRatio: false,
|
|
||||||
plugins: {
|
|
||||||
legend: {
|
|
||||||
display: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
scales: {
|
|
||||||
x: {
|
|
||||||
grid: {
|
|
||||||
color: 'rgba(255, 255, 255, 0.1)'
|
|
||||||
},
|
|
||||||
ticks: {
|
|
||||||
color: '#9ca3af'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
y: {
|
|
||||||
grid: {
|
|
||||||
color: 'rgba(255, 255, 255, 0.1)'
|
|
||||||
},
|
|
||||||
ticks: {
|
|
||||||
color: '#9ca3af'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
<?php
|
|
||||||
define('TELEGRAM_BOT_TOKEN', '8049813269:AAElj4gDKW_aftXylnsSZvLAJMy5u1o09W4');
|
|
||||||
@ -1,76 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once 'db/config.php';
|
|
||||||
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
|
|
||||||
// Fetch total publics
|
|
||||||
$stmt_publics = $pdo->query("SELECT COUNT(*) as total_publics FROM publics");
|
|
||||||
$total_publics = $stmt_publics->fetchColumn();
|
|
||||||
|
|
||||||
// Fetch total subscribers
|
|
||||||
$stmt_subscribers = $pdo->query("SELECT SUM(subscribers) as total_subscribers FROM publics");
|
|
||||||
$total_subscribers = $stmt_subscribers->fetchColumn();
|
|
||||||
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
// For a real app, you'd want to log this error, not die.
|
|
||||||
die("Database error: " . $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to format large numbers
|
|
||||||
function format_number($num) {
|
|
||||||
if ($num >= 1000000) {
|
|
||||||
return round($num / 1000000, 1) . 'M';
|
|
||||||
} elseif ($num >= 1000) {
|
|
||||||
return round($num / 1000, 1) . 'K';
|
|
||||||
}
|
|
||||||
return $num;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<header class="mb-4">
|
|
||||||
<h1 class="h3">Dashboard</h1>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<!-- Stat Cards -->
|
|
||||||
<div class="row g-4 mb-4">
|
|
||||||
<div class="col-md-6 col-lg-3">
|
|
||||||
<div class="card stat-card p-3">
|
|
||||||
<h5 class="card-title">Total Subscribers</h5>
|
|
||||||
<p class="display-4 fw-bold"><?php echo format_number($total_subscribers ?? 0); ?></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6 col-lg-3">
|
|
||||||
<div class="card stat-card p-3">
|
|
||||||
<h5 class="card-title">Avg. Views / Post</h5>
|
|
||||||
<p class="display-4 fw-bold">-</p> <!-- Placeholder -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6 col-lg-3">
|
|
||||||
<div class="card stat-card p-3">
|
|
||||||
<h5 class="card-title">Monthly Income</h5>
|
|
||||||
<p class="display-4 fw-bold">-</p> <!-- Placeholder -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6 col-lg-3">
|
|
||||||
<div class="card stat-card p-3">
|
|
||||||
<h5 class="card-title">Active Publics</h5>
|
|
||||||
<p class="display-4 fw-bold"><?php echo $total_publics ?? 0; ?></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Chart -->
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="card-title mb-0">Average Views Over Time</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body" style="height: 400px;">
|
|
||||||
<canvas id="viewsChart"></canvas>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
function getSubscriberCount($channel_id, $token) {
|
|
||||||
// Prepend "@" if it's a public channel username without it
|
|
||||||
if (strpos($channel_id, '@') !== 0 && strpos($channel_id, '-') !== 0) {
|
|
||||||
$channel_id = '@' . $channel_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = "https://api.telegram.org/bot{$token}/getChatMemberCount?chat_id=" . urlencode($channel_id);
|
|
||||||
|
|
||||||
$response = @file_get_contents($url);
|
|
||||||
if ($response === FALSE) {
|
|
||||||
// Could log an error here
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = json_decode($response, true);
|
|
||||||
|
|
||||||
if (isset($data['ok']) && $data['ok'] === true) {
|
|
||||||
return $data['result'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Could log $data['description']
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
203
index.php
203
index.php
@ -1,67 +1,150 @@
|
|||||||
<!DOCTYPE html>
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
@ini_set('display_errors', '1');
|
||||||
|
@error_reporting(E_ALL);
|
||||||
|
@date_default_timezone_set('UTC');
|
||||||
|
|
||||||
|
$phpVersion = PHP_VERSION;
|
||||||
|
$now = date('Y-m-d H:i:s');
|
||||||
|
?>
|
||||||
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>Telegram Channels Dashboard</title>
|
<title>New Style</title>
|
||||||
<meta name="description" content="Admin panel for managing Telegram channels, content scheduling, and statistics. Built with Flatlogic Generator.">
|
<?php
|
||||||
<meta name="keywords" content="telegram admin, telegram dashboard, n8n telegram, telegram analytics, content scheduler, telegram revenue, channel management, telegram stats, Built with Flatlogic Generator">
|
// Read project preview data from environment
|
||||||
|
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||||
<meta property="og:title" content="Telegram Channels Dashboard">
|
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||||
<meta property="og:description" content="Admin panel for managing Telegram channels, content scheduling, and statistics.">
|
?>
|
||||||
<meta property="og:image" content="">
|
<?php if ($projectDescription): ?>
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
<!-- Meta description -->
|
||||||
<meta name="twitter:image" content="">
|
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||||
|
<!-- Open Graph meta tags -->
|
||||||
<!-- Bootstrap 5 CSS -->
|
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
<!-- Twitter meta tags -->
|
||||||
<!-- Bootstrap Icons -->
|
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivrnet.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
<?php endif; ?>
|
||||||
<!-- Custom CSS -->
|
<?php if ($projectImageUrl): ?>
|
||||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
<!-- Open Graph image -->
|
||||||
|
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||||
|
<!-- Twitter image -->
|
||||||
|
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||||
|
<?php endif; ?>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--bg-color-start: #6a11cb;
|
||||||
|
--bg-color-end: #2575fc;
|
||||||
|
--text-color: #ffffff;
|
||||||
|
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||||
|
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
font-family: 'Inter', sans-serif;
|
||||||
|
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||||
|
color: var(--text-color);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 100vh;
|
||||||
|
text-align: center;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
body::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||||
|
animation: bg-pan 20s linear infinite;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
@keyframes bg-pan {
|
||||||
|
0% { background-position: 0% 0%; }
|
||||||
|
100% { background-position: 100% 100%; }
|
||||||
|
}
|
||||||
|
main {
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
.card {
|
||||||
|
background: var(--card-bg-color);
|
||||||
|
border: 1px solid var(--card-border-color);
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 2rem;
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
-webkit-backdrop-filter: blur(20px);
|
||||||
|
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.loader {
|
||||||
|
margin: 1.25rem auto 1.25rem;
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||||
|
border-top-color: #fff;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
}
|
||||||
|
@keyframes spin {
|
||||||
|
from { transform: rotate(0deg); }
|
||||||
|
to { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
.hint {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
.sr-only {
|
||||||
|
position: absolute;
|
||||||
|
width: 1px; height: 1px;
|
||||||
|
padding: 0; margin: -1px;
|
||||||
|
overflow: hidden;
|
||||||
|
clip: rect(0, 0, 0, 0);
|
||||||
|
white-space: nowrap; border: 0;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 3rem;
|
||||||
|
font-weight: 700;
|
||||||
|
margin: 0 0 1rem;
|
||||||
|
letter-spacing: -1px;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
margin: 0.5rem 0;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
code {
|
||||||
|
background: rgba(0,0,0,0.2);
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||||
|
}
|
||||||
|
footer {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 1rem;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php $page = $_GET['page'] ?? 'dashboard'; ?>
|
<main>
|
||||||
<div class="sidebar">
|
<div class="card">
|
||||||
<a href="index.php" class="logo">TG Panel</a>
|
<h1>Analyzing your requirements and generating your website…</h1>
|
||||||
<ul class="nav flex-column">
|
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||||
<li class="nav-item">
|
<span class="sr-only">Loading…</span>
|
||||||
<a class="nav-link <?php echo ($page === 'dashboard') ? 'active' : ''; ?>" href="index.php?page=dashboard"><i class="bi bi-grid-1x2-fill"></i> Dashboard</a>
|
</div>
|
||||||
</li>
|
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||||
<li class="nav-item">
|
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||||
<a class="nav-link <?php echo ($page === 'publics') ? 'active' : ''; ?>" href="index.php?page=publics"><i class="bi bi-telegram"></i> Publics</a>
|
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link <?php echo ($page === 'scheduler') ? 'active' : ''; ?>" href="index.php?page=scheduler"><i class="bi bi-calendar-week-fill"></i> Scheduler</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link <?php echo ($page === 'statistics') ? 'active' : ''; ?>" href="index.php?page=statistics"><i class="bi bi-bar-chart-line-fill"></i> Statistics</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link <?php echo ($page === 'revenue') ? 'active' : ''; ?>" href="index.php?page=revenue"><i class="bi bi-cash-coin"></i> Revenue</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
|
</main>
|
||||||
<div class="main-content">
|
<footer>
|
||||||
<?php
|
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||||
$page_file = $page . '.php';
|
</footer>
|
||||||
$allowed_pages = ['dashboard.php', 'publics.php', 'scheduler.php', 'statistics.php', 'revenue.php'];
|
|
||||||
|
|
||||||
if (in_array($page_file, $allowed_pages) && file_exists($page_file)) {
|
|
||||||
include($page_file);
|
|
||||||
} else {
|
|
||||||
// You can include a 404 page here
|
|
||||||
echo '<div class="card"><div class="card-body"><h1>404 - Страница не найдена</h1><p>Запрошенная страница не существует.</p></div></div>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Bootstrap 5 JS -->
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
||||||
<!-- Chart.js -->
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
||||||
<!-- Custom JS -->
|
|
||||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
156
publics.php
156
publics.php
@ -1,156 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once 'db/config.php';
|
|
||||||
require_once 'config.php';
|
|
||||||
require_once 'includes/telegram_api.php';
|
|
||||||
|
|
||||||
$message = '';
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] == 'add_public') {
|
|
||||||
$title = $_POST['title'] ?? '';
|
|
||||||
$username = $_POST['username'] ?? '';
|
|
||||||
$telegrams_id = $_POST['telegrams_id'] ?? null;
|
|
||||||
|
|
||||||
if (!empty($title) && !empty($telegrams_id)) {
|
|
||||||
$subscribers = getSubscriberCount($telegrams_id, TELEGRAM_BOT_TOKEN);
|
|
||||||
if ($subscribers === null) {
|
|
||||||
$subscribers = 0;
|
|
||||||
$message = '<div class="alert alert-warning">Не удалось получить количество подписчиков. Канал добавлен со значением 0.</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
$stmt = $pdo->prepare("INSERT INTO publics (title, username, telegrams_id, subscribers) VALUES (?, ?, ?, ?)");
|
|
||||||
$stmt->execute([$title, $username, $telegrams_id, $subscribers]);
|
|
||||||
$message .= '<div class="alert alert-success">Канал успешно добавлен!</div>';
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$message = '<div class="alert alert-danger">Ошибка: ' . $e->getMessage() . '</div>';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$message = '<div class="alert alert-danger">Название и ID канала обязательны.</div>';
|
|
||||||
}
|
|
||||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] == 'refresh_public') {
|
|
||||||
$id = $_POST['id'] ?? null;
|
|
||||||
if ($id) {
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
$stmt = $pdo->prepare("SELECT telegrams_id FROM publics WHERE id = ?");
|
|
||||||
$stmt->execute([$id]);
|
|
||||||
$public = $stmt->fetch();
|
|
||||||
|
|
||||||
if ($public) {
|
|
||||||
$telegrams_id = $public['telegrams_id'];
|
|
||||||
$subscribers = getSubscriberCount($telegrams_id, TELEGRAM_BOT_TOKEN);
|
|
||||||
|
|
||||||
if ($subscribers !== null) {
|
|
||||||
$updateStmt = $pdo->prepare("UPDATE publics SET subscribers = ? WHERE id = ?");
|
|
||||||
$updateStmt->execute([$subscribers, $id]);
|
|
||||||
$message = '<div class="alert alert-success">Количество подписчиков обновлено!</div>';
|
|
||||||
} else {
|
|
||||||
$message = '<div class="alert alert-warning">Не удалось обновить количество подписчиков. API Telegram не ответило.</div>';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$message = '<div class="alert alert-danger">Канал не найден.</div>';
|
|
||||||
}
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$message = '<div class="alert alert-danger">Ошибка: ' . $e->getMessage() . '</div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
$stmt = $pdo->query("SELECT id, title, username, subscribers, telegrams_id FROM publics ORDER BY created_at DESC");
|
|
||||||
$publics = $stmt->fetchAll();
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
die("Ошибка загрузки каналов: " . $e->getMessage());
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<header class="mb-4 d-flex justify-content-between align-items-center">
|
|
||||||
<h1 class="h3">Управление пабликами</h1>
|
|
||||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addPublicModal">
|
|
||||||
<i class="bi bi-plus-circle"></i> Добавить паблик
|
|
||||||
</button>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<?php echo $message; ?>
|
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="card-title mb-0">Список ваших каналов</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-dark table-striped table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>ID</th>
|
|
||||||
<th>Название</th>
|
|
||||||
<th>Username</th>
|
|
||||||
<th>Telegram ID</th>
|
|
||||||
<th>Подписчики</th>
|
|
||||||
<th>Действия</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php if (empty($publics)): ?>
|
|
||||||
<tr>
|
|
||||||
<td colspan="6" class="text-center">Вы еще не добавили ни одного канала.</td>
|
|
||||||
</tr>
|
|
||||||
<?php else: ?>
|
|
||||||
<?php foreach ($publics as $public): ?>
|
|
||||||
<tr>
|
|
||||||
<td><?php echo htmlspecialchars($public['id']); ?></td>
|
|
||||||
<td><?php echo htmlspecialchars($public['title']); ?></td>
|
|
||||||
<td><?php echo $public['username'] ? '@' . htmlspecialchars($public['username']) : 'N/A'; ?></td>
|
|
||||||
<td><?php echo htmlspecialchars($public['telegrams_id']); ?></td>
|
|
||||||
<td><?php echo htmlspecialchars($public['subscribers']); ?></td>
|
|
||||||
<td>
|
|
||||||
<form action="index.php?page=publics" method="POST" class="d-inline-block">
|
|
||||||
<input type="hidden" name="action" value="refresh_public">
|
|
||||||
<input type="hidden" name="id" value="<?php echo $public['id']; ?>">
|
|
||||||
<button type="submit" class="btn btn-sm btn-outline-info" title="Обновить подписчиков">
|
|
||||||
<i class="bi bi-arrow-repeat"></i>
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
<button class="btn btn-sm btn-outline-light" title="Редактировать"><i class="bi bi-pencil"></i></button>
|
|
||||||
<button class="btn btn-sm btn-outline-danger" title="Удалить"><i class="bi bi-trash"></i></button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Modal -->
|
|
||||||
<div class="modal fade" id="addPublicModal" tabindex="-1" aria-labelledby="addPublicModalLabel" aria-hidden="true">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content bg-dark text-white">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title" id="addPublicModalLabel">Добавить новый паблик</h5>
|
|
||||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<form action="index.php?page=publics" method="POST">
|
|
||||||
<input type="hidden" name="action" value="add_public">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="title" class="form-label">Название канала</label>
|
|
||||||
<input type="text" class="form-control" id="title" name="title" required>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="username" class="form-label">Username канала (без @)</label>
|
|
||||||
<input type="text" class="form-control" id="username" name="username">
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="telegrams_id" class="form-label">Telegram ID канала</label>
|
|
||||||
<input type="text" class="form-control" id="telegrams_id" name="telegrams_id" required>
|
|
||||||
<div class="form-text">Для публичных каналов - @username, для приватных - ID (например, -100123456789).</div>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary">Добавить</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
<header class="mb-4">
|
|
||||||
<h1 class="h3">Доходы</h1>
|
|
||||||
</header>
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<p class="text-secondary">Здесь будет дашборд для отслеживания доходов от рекламы. Вы сможете добавлять записи о рекламных размещениях и видеть общую прибыльность по каждому каналу и за периоды.</p>
|
|
||||||
<!-- Placeholder for revenue charts/tables -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
<header class="mb-4">
|
|
||||||
<h1 class="h3">Планировщик публикаций</h1>
|
|
||||||
</header>
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<p class="text-secondary">Здесь будет сетка календаря для планирования постов в ваших каналах. Вы сможете создавать, перетаскивать и редактировать запланированные публикации.</p>
|
|
||||||
<!-- Placeholder for calendar/grid -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
<header class="mb-4">
|
|
||||||
<h1 class="h3">Статистика</h1>
|
|
||||||
</header>
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<p class="text-secondary">Здесь будут подробные графики и отчеты по подписчикам, просмотрам, охватам и другим метрикам для каждого из ваших каналов.</p>
|
|
||||||
<!-- Placeholder for charts -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user