This commit is contained in:
Flatlogic Bot 2025-10-27 12:24:10 +00:00
parent 0eff6ab005
commit 74e14f325c
6 changed files with 364 additions and 146 deletions

82
add_channel.php Normal file
View File

@ -0,0 +1,82 @@
<?php
require_once __DIR__ . '/db/config.php';
$error = '';
$telegram_id = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$telegram_id = trim($_POST['telegram_id'] ?? '');
if (empty($telegram_id)) {
$error = 'Telegram Channel ID or URL is required.';
} else {
// Basic parsing to get ID from URL
if (filter_var($telegram_id, FILTER_VALIDATE_URL)) {
$path = parse_url($telegram_id, PHP_URL_PATH);
$telegram_id = basename($path);
}
// Prepend '@' if it's a public username without it
if (strpos($telegram_id, '@') !== 0 && !is_numeric($telegram_id)) {
$telegram_id = '@' . $telegram_id;
}
try {
$pdo = db();
$stmt = $pdo->prepare("INSERT INTO channels (telegram_id) VALUES (:telegram_id)");
$stmt->execute([':telegram_id' => $telegram_id]);
session_start();
$_SESSION['flash_message'] = "Channel '{$telegram_id}' added successfully!";
header("Location: index.php");
exit;
} catch (PDOException $e) {
if ($e->errorInfo[1] == 1062) { // Duplicate entry
$error = "Error: Channel '{$telegram_id}' already exists.";
} else {
$error = "Database error: " . $e->getMessage();
}
}
}
}
require_once __DIR__ . '/layout_header.php';
?>
<div class="container-fluid">
<h1 class="h2 mb-4">Add New Channel</h1>
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-body">
<?php if ($error): ?>
<div class="alert alert-danger"><?php echo htmlspecialchars($error); ?></div>
<?php endif; ?>
<form action="add_channel.php" method="POST">
<div class="mb-3">
<label for="telegram_id" class="form-label">Telegram Channel ID or URL</label>
<input type="text" class="form-control" id="telegram_id" name="telegram_id"
placeholder="e.g., @channelname or https://t.me/channelname"
value="<?php echo htmlspecialchars($telegram_id); ?>" required>
<div class="form-text text-secondary-color">
Provide the public channel username (e.g., @durov) or full URL.
</div>
</div>
<button type="submit" class="btn btn-primary">
<i data-feather="plus" class="me-1" style="width:16px; height:16px;"></i>
Add Channel
</button>
<a href="index.php" class="btn btn-secondary">Cancel</a>
</form>
</div>
</div>
</div>
</div>
</div>
<?php
require_once __DIR__ . '/layout_footer.php';
?>

135
assets/css/custom.css Normal file
View File

@ -0,0 +1,135 @@
:root {
--bg-color: #121212;
--surface-color: #1E1E1E;
--primary-color: #00A8FF;
--secondary-color: #4CAF50;
--text-color: #FFFFFF;
--text-secondary-color: #B0B0B0;
--border-color: #2c2c2c;
--font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
--border-radius: 8px;
}
body {
background-color: var(--bg-color);
color: var(--text-color);
font-family: var(--font-family);
font-size: 16px;
}
.sidebar {
width: 250px;
background-color: var(--surface-color);
height: 100vh;
position: fixed;
top: 0;
left: 0;
padding: 1.5rem 1rem;
border-right: 1px solid var(--border-color);
}
.sidebar-header {
margin-bottom: 2rem;
}
.sidebar-brand {
display: flex;
align-items: center;
font-size: 1.5rem;
font-weight: 700;
color: var(--text-color);
text-decoration: none;
}
.sidebar-brand .brand-icon {
color: var(--primary-color);
margin-right: 0.75rem;
}
.sidebar .nav-link {
color: var(--text-secondary-color);
display: flex;
align-items: center;
padding: 0.75rem 1rem;
border-radius: var(--border-radius);
margin-bottom: 0.5rem;
transition: background-color 0.2s ease, color 0.2s ease;
}
.sidebar .nav-link i {
margin-right: 1rem;
width: 20px;
height: 20px;
}
.sidebar .nav-link:hover {
background-color: rgba(255, 255, 255, 0.05);
color: var(--text-color);
}
.sidebar .nav-link.active {
background-color: var(--primary-color);
color: var(--text-color);
}
.main-content {
margin-left: 250px;
padding: 2rem;
}
.card {
background-color: var(--surface-color);
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
}
.card-header {
background-color: rgba(255, 255, 255, 0.03);
border-bottom: 1px solid var(--border-color);
}
.btn-primary {
background-color: var(--primary-color);
border-color: var(--primary-color);
font-weight: 600;
transition: background-color 0.2s ease, border-color 0.2s ease;
}
.btn-primary:hover {
background-color: #0094e0;
border-color: #0094e0;
}
.form-control, .form-select {
background-color: var(--bg-color);
border-color: var(--border-color);
color: var(--text-color);
border-radius: var(--border-radius);
}
.form-control:focus, .form-select:focus {
background-color: var(--bg-color);
border-color: var(--primary-color);
color: var(--text-color);
box-shadow: 0 0 0 0.25rem rgba(0, 168, 255, 0.25);
}
.form-control::placeholder {
color: var(--text-secondary-color);
}
.toast {
background-color: var(--surface-color);
color: var(--text-color);
border: 1px solid var(--border-color);
}
.toast-header {
background-color: rgba(255, 255, 255, 0.05);
color: var(--text-color);
border-bottom: 1px solid var(--border-color);
}
.btn-close {
filter: invert(1) grayscale(100%) brightness(200%);
}

3
assets/js/main.js Normal file
View File

@ -0,0 +1,3 @@
// Empty for now, can be used for more complex interactions later.
console.log("main.js loaded");

187
index.php
View File

@ -1,150 +1,47 @@
<?php <?php
declare(strict_types=1); require_once __DIR__ . '/db/config.php';
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$phpVersion = PHP_VERSION; // Simple migration runner
$now = date('Y-m-d H:i:s'); try {
$pdo = db();
$pdo->exec("CREATE TABLE IF NOT EXISTS channels (id INT AUTO_INCREMENT PRIMARY KEY, telegram_id VARCHAR(255) NOT NULL UNIQUE, name VARCHAR(255), avatar_url VARCHAR(255), description TEXT, subscribers INT, added_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP);");
} catch (PDOException $e) {
// In a real app, log this error. For now, we die.
die("Database migration failed: " . $e->getMessage());
}
// Fetch channel count
$stmt = $pdo->query("SELECT COUNT(*) FROM channels");
$channel_count = $stmt->fetchColumn();
require_once __DIR__ . '/layout_header.php';
?> ?>
<!doctype html>
<html lang="en"> <div class="container-fluid">
<head> <h1 class="h2 mb-4">Dashboard</h1>
<meta charset="utf-8" /> <div class="row">
<meta name="viewport" content="width=device-width, initial-scale=1" /> <div class="col-md-4">
<title>New Style</title> <div class="card text-white">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<div>
<h5 class="card-title">Total Channels</h5>
<p class="card-text fs-2 fw-bold"><?php echo $channel_count; ?></p>
</div>
<div class="fs-1 text-primary">
<i data-feather="tv"></i>
</div>
</div>
<a href="add_channel.php" class="btn btn-primary mt-3">
<i data-feather="plus" class="me-1" style="width:16px; height:16px;"></i>
Add Channel
</a>
</div>
</div>
</div>
</div>
</div>
<?php <?php
// Read project preview data from environment require_once __DIR__ . '/layout_footer.php';
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?> ?>
<?php if ($projectDescription): ?>
<!-- Meta description -->
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags -->
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Twitter meta tags -->
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- 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>
<body>
<main>
<div class="card">
<h1>Analyzing your requirements and generating your website…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
</div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will update automatically as the plan is implemented.</p>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
</body>
</html>

19
layout_footer.php Normal file
View File

@ -0,0 +1,19 @@
</main>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script>
feather.replace();
// Auto-hide toast
const flashToast = document.getElementById('flashToast');
if (flashToast) {
const toast = new bootstrap.Toast(flashToast, { delay: 5000 });
toast.show();
}
</script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>

82
layout_header.php Normal file
View File

@ -0,0 +1,82 @@
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>telegra</title>
<meta name="description" content="Custom CRM System for Managing Multiple Telegram Public Channels. Built with Flatlogic Generator.">
<meta name="keywords" content="telegram crm, channel management, post scheduler, telegram analytics, content automation, n8n integration, telegram pubs, social media tool, Built with Flatlogic Generator">
<meta property="og:title" content="telegra">
<meta property="og:description" content="Custom CRM System for Managing Multiple Telegram Public Channels. Built with Flatlogic Generator.">
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<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;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<div class="d-flex">
<nav class="sidebar">
<div class="sidebar-header">
<a href="index.php" class="sidebar-brand">
<i data-feather="send" class="brand-icon"></i>
<span>telegra</span>
</a>
</div>
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="index.php">
<i data-feather="home"></i>
<span>Dashboard</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<i data-feather="tv"></i>
<span>Channels</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<i data-feather="calendar"></i>
<span>Scheduler</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<i data-feather="bar-chart-2"></i>
<span>Analytics</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<i data-feather="settings"></i>
<span>Settings</span>
</a>
</li>
</ul>
</nav>
<main class="main-content flex-grow-1">
<?php if (isset($_SESSION['flash_message'])): ?>
<div class="toast-container position-fixed top-0 end-0 p-3">
<div id="flashToast" class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<strong class="me-auto">Notification</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
<?php echo $_SESSION['flash_message']; ?>
</div>
</div>
</div>
<?php unset($_SESSION['flash_message']); ?>
<?php endif; ?>