Update index.php
This commit is contained in:
141
index.php
141
index.php
@@ -1,22 +1,67 @@
|
|||||||
<?php
|
<?php
|
||||||
// Simple example post data — you can swap this out for a database later.
|
/*
|
||||||
|
Minimal DB schema for Mediakor posts:
|
||||||
|
|
||||||
|
CREATE TABLE posts (
|
||||||
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
title VARCHAR(255) NOT NULL,
|
||||||
|
meta VARCHAR(255) DEFAULT NULL,
|
||||||
|
body TEXT NOT NULL,
|
||||||
|
is_published TINYINT(1) NOT NULL DEFAULT 1,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
Insert example:
|
||||||
|
|
||||||
|
INSERT INTO posts (title, meta, body) VALUES
|
||||||
|
('Welcome to Mediakor', 'System Log • Today',
|
||||||
|
'Mediakor is your central hub for projects, servers, and experiments. Use the nav on the left to explore each sector of the network.');
|
||||||
|
*/
|
||||||
|
|
||||||
|
// --- DB CONFIG ---
|
||||||
|
// You can also set these as environment variables in your Docker stack
|
||||||
|
$dbHost = $_ENV['DB_HOST'] ?? 'localhost';
|
||||||
|
$dbName = $_ENV['DB_NAME'] ?? 'mediakor';
|
||||||
|
$dbUser = $_ENV['DB_USER'] ?? 'mediakor';
|
||||||
|
$dbPass = $_ENV['DB_PASS'] ?? 'mediakor_password';
|
||||||
|
|
||||||
|
$posts = [];
|
||||||
|
$dbError = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dsn = "mysql:host={$dbHost};dbname={$dbName};charset=utf8mb4";
|
||||||
|
$pdo = new PDO($dsn, $dbUser, $dbPass, [
|
||||||
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||||
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$stmt = $pdo->query("
|
||||||
|
SELECT id, title, meta, body, created_at
|
||||||
|
FROM posts
|
||||||
|
WHERE is_published = 1
|
||||||
|
ORDER BY created_at DESC, id DESC
|
||||||
|
");
|
||||||
|
$posts = $stmt->fetchAll();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// Fallback: static posts if DB connection fails
|
||||||
|
$dbError = 'DB_connect_failed';
|
||||||
$posts = [
|
$posts = [
|
||||||
[
|
[
|
||||||
|
'id' => 0,
|
||||||
'title' => 'Welcome to Mediakor',
|
'title' => 'Welcome to Mediakor',
|
||||||
'meta' => 'System Log • Today',
|
'meta' => 'System Log • Fallback',
|
||||||
'body' => 'Mediakor is your central hub for projects, servers, and experiments. Use the nav on the left to explore each sector of the network.'
|
'body' => 'Database connection failed, so this is the static fallback feed. Once your DB is configured, posts will be served from the posts table.',
|
||||||
|
'created_at' => null,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'title' => 'Status: Core Services Online',
|
'id' => 0,
|
||||||
'meta' => 'Monitoring • Uptime',
|
'title' => 'Configure Database',
|
||||||
'body' => 'Web stack, game servers, and media nodes are all reporting nominal. Check the “Status Panel” section for real-time dashboards.'
|
'meta' => 'Setup • Guide',
|
||||||
],
|
'body' => 'Edit the DB settings at the top of index.php and create the posts table using the SQL snippet in the comment.',
|
||||||
[
|
'created_at' => null,
|
||||||
'title' => 'Latest Deployment',
|
|
||||||
'meta' => 'Deploy • v1.0',
|
|
||||||
'body' => 'A new build has been pushed to the cluster. Patch notes, changelogs, and rollback instructions are available in the Documentation dock.'
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@@ -53,20 +98,49 @@ $posts = [
|
|||||||
display:flex;
|
display:flex;
|
||||||
flex-direction:column;
|
flex-direction:column;
|
||||||
overflow-x:hidden;
|
overflow-x:hidden;
|
||||||
|
position:relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* subtle stars */
|
/* Twinkling starfields (two layers, desynced animation) */
|
||||||
body::before{
|
body::before,
|
||||||
|
body::after{
|
||||||
content:"";
|
content:"";
|
||||||
position:fixed;
|
position:fixed;
|
||||||
inset:-200px;
|
inset:-200px;
|
||||||
background-image:
|
pointer-events:none;
|
||||||
radial-gradient(1px 1px at 10% 20%,rgba(255,255,255,.25) 0,transparent 60%),
|
|
||||||
radial-gradient(1px 1px at 40% 80%,rgba(255,255,255,.2) 0,transparent 60%),
|
|
||||||
radial-gradient(1px 1px at 80% 30%,rgba(255,255,255,.2) 0,transparent 60%),
|
|
||||||
radial-gradient(1px 1px at 20% 60%,rgba(255,255,255,.18) 0,transparent 60%);
|
|
||||||
opacity:0.35;
|
|
||||||
z-index:-1;
|
z-index:-1;
|
||||||
|
background-repeat:no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
body::before{
|
||||||
|
background-image:
|
||||||
|
radial-gradient(1px 1px at 10% 20%,rgba(255,255,255,.40) 0,transparent 60%),
|
||||||
|
radial-gradient(1px 1px at 40% 80%,rgba(255,255,255,.25) 0,transparent 60%),
|
||||||
|
radial-gradient(1px 1px at 80% 30%,rgba(255,255,255,.30) 0,transparent 60%),
|
||||||
|
radial-gradient(1px 1px at 20% 60%,rgba(255,255,255,.22) 0,transparent 60%),
|
||||||
|
radial-gradient(1px 1px at 65% 50%,rgba(255,255,255,.20) 0,transparent 60%);
|
||||||
|
animation:twinkleLayer1 14s linear infinite alternate;
|
||||||
|
}
|
||||||
|
|
||||||
|
body::after{
|
||||||
|
background-image:
|
||||||
|
radial-gradient(1px 1px at 15% 75%,rgba(255,255,255,.25) 0,transparent 60%),
|
||||||
|
radial-gradient(1px 1px at 70% 15%,rgba(255,255,255,.30) 0,transparent 60%),
|
||||||
|
radial-gradient(1px 1px at 90% 60%,rgba(255,255,255,.22) 0,transparent 60%),
|
||||||
|
radial-gradient(1px 1px at 35% 35%,rgba(255,255,255,.27) 0,transparent 60%);
|
||||||
|
animation:twinkleLayer2 18s linear infinite alternate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes twinkleLayer1{
|
||||||
|
0% {opacity:0.25; transform:translate3d(0,0,0);}
|
||||||
|
50% {opacity:0.55; transform:translate3d(10px,-8px,0);}
|
||||||
|
100%{opacity:0.20; transform:translate3d(-8px,6px,0);}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes twinkleLayer2{
|
||||||
|
0% {opacity:0.18; transform:translate3d(0,0,0);}
|
||||||
|
50% {opacity:0.50; transform:translate3d(-12px,10px,0);}
|
||||||
|
100%{opacity:0.22; transform:translate3d(8px,-6px,0);}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Header */
|
/* Header */
|
||||||
@@ -507,6 +581,9 @@ $posts = [
|
|||||||
<span>Sector: Outer Net</span>
|
<span>Sector: Outer Net</span>
|
||||||
</div>
|
</div>
|
||||||
<span>All traffic through Mediakor is monitored for anomalies and uptime.</span>
|
<span>All traffic through Mediakor is monitored for anomalies and uptime.</span>
|
||||||
|
<?php if ($dbError): ?>
|
||||||
|
<span style="color:#f97373;margin-top:4px;">DB status: offline (showing fallback posts)</span>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
@@ -523,12 +600,32 @@ $posts = [
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mk-post-list">
|
<div class="mk-post-list">
|
||||||
|
<?php if (empty($posts)): ?>
|
||||||
|
<article class="mk-post">
|
||||||
|
<div class="mk-post-inner">
|
||||||
|
<header class="mk-post-header">
|
||||||
|
<h3 class="mk-post-title">No Posts Yet</h3>
|
||||||
|
<div class="mk-post-meta">Setup • Info</div>
|
||||||
|
</header>
|
||||||
|
<div class="mk-post-body">
|
||||||
|
Use phpMyAdmin or your SQL client to insert rows into the <code>posts</code> table and they will appear here automatically.
|
||||||
|
</div>
|
||||||
|
<footer class="mk-post-footer">
|
||||||
|
<span class="mk-pill">System</span>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
<?php else: ?>
|
||||||
<?php foreach ($posts as $post): ?>
|
<?php foreach ($posts as $post): ?>
|
||||||
<article class="mk-post">
|
<article class="mk-post">
|
||||||
<div class="mk-post-inner">
|
<div class="mk-post-inner">
|
||||||
<header class="mk-post-header">
|
<header class="mk-post-header">
|
||||||
<h3 class="mk-post-title"><?php echo htmlspecialchars($post['title']); ?></h3>
|
<h3 class="mk-post-title">
|
||||||
<div class="mk-post-meta"><?php echo htmlspecialchars($post['meta']); ?></div>
|
<?php echo htmlspecialchars($post['title']); ?>
|
||||||
|
</h3>
|
||||||
|
<div class="mk-post-meta">
|
||||||
|
<?php echo htmlspecialchars($post['meta'] ?? 'Log Entry'); ?>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div class="mk-post-body">
|
<div class="mk-post-body">
|
||||||
<?php echo nl2br(htmlspecialchars($post['body'])); ?>
|
<?php echo nl2br(htmlspecialchars($post['body'])); ?>
|
||||||
@@ -536,6 +633,7 @@ $posts = [
|
|||||||
<footer class="mk-post-footer">
|
<footer class="mk-post-footer">
|
||||||
<span class="mk-pill">Log Entry</span>
|
<span class="mk-pill">Log Entry</span>
|
||||||
<div class="mk-post-actions">
|
<div class="mk-post-actions">
|
||||||
|
<!-- These could later link to a dedicated post page or admin tools -->
|
||||||
<button type="button">View Details</button>
|
<button type="button">View Details</button>
|
||||||
<button type="button">Pin</button>
|
<button type="button">Pin</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -543,6 +641,7 @@ $posts = [
|
|||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
Reference in New Issue
Block a user