Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2498d9e452 | ||
|
|
4be8924eba |
18
.htaccess
18
.htaccess
@ -1,18 +1,4 @@
|
||||
DirectoryIndex index.php index.html
|
||||
Options -Indexes
|
||||
Options -MultiViews
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# 0) Serve existing files/directories as-is
|
||||
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -d
|
||||
RewriteRule ^ - [L]
|
||||
|
||||
# 1) Internal map: /page or /page/ -> /page.php (if such PHP file exists)
|
||||
RewriteCond %{REQUEST_FILENAME}.php -f
|
||||
RewriteRule ^(.+?)/?$ $1.php [L]
|
||||
|
||||
# 2) Optional: strip trailing slash for non-directories (keeps .php links working)
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^(.+)/$ $1 [R=301,L]
|
||||
RewriteRule ^post/([a-zA-Z0-9-]+)$ post.php?slug=$1 [L]
|
||||
115
admin.php
Normal file
115
admin.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$pageTitle = 'Admin';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
function slugify($text) {
|
||||
$text = preg_replace('~[\pL\d]+~u', '-', $text);
|
||||
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
|
||||
$text = preg_replace('~[^\-\w]+~', '', $text);
|
||||
$text = trim($text, '-');
|
||||
$text = preg_replace('~-+~', '-', $text);
|
||||
$text = strtolower($text);
|
||||
if (empty($text)) {
|
||||
return 'n-a';
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
$message = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$title = $_POST['title'] ?? '';
|
||||
$content = $_POST['content'] ?? '';
|
||||
$author = $_POST['author'] ?? '';
|
||||
$slug = slugify($title);
|
||||
|
||||
if ($title && $content && $author) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("INSERT INTO posts (title, content, author, slug) VALUES (?, ?, ?, ?)");
|
||||
$stmt->execute([$title, $content, $author, $slug]);
|
||||
$message = '<div class="alert alert-success">Post created successfully!</div>';
|
||||
} catch (PDOException $e) {
|
||||
$message = '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
|
||||
}
|
||||
} else {
|
||||
$message = '<div class="alert alert-danger">Please fill in all fields.</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<h1>Add New Post <a href="logout.php" class="btn btn-sm btn-danger">Logout</a></h1>
|
||||
|
||||
<?php echo $message; ?>
|
||||
|
||||
<form method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label">Title</label>
|
||||
<input type="text" class="form-control" id="title" name="title" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="author" class="form-label">Author</label>
|
||||
<input type="text" class="form-control" id="author" name="author" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="content" class="form-label">Content</label>
|
||||
<textarea class="form-control" id="content" name="content" rows="10" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Create Post</button>
|
||||
</form>
|
||||
|
||||
<hr class="my-5">
|
||||
|
||||
<h2 class="mt-5">Manage Posts</h2>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">Title</th>
|
||||
<th scope="col">Author</th>
|
||||
<th scope="col">Created At</th>
|
||||
<th scope="col">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->query("SELECT id, title, author, created_at FROM posts ORDER BY created_at DESC");
|
||||
$posts = $stmt->fetchAll();
|
||||
|
||||
if ($posts) {
|
||||
foreach ($posts as $post) {
|
||||
echo "<tr>";
|
||||
echo "<th scope=\"row\">" . htmlspecialchars($post['id']) . "</th>";
|
||||
echo "<td>" . htmlspecialchars($post['title']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($post['author']) . "</td>";
|
||||
echo "<td>" . date("F j, Y, g:i a", strtotime($post['created_at'])) . "</td>";
|
||||
echo '<td>
|
||||
<a href="post.php?slug=' . htmlspecialchars($post['slug']) . '" class="btn btn-sm btn-info">View</a>
|
||||
<a href="edit.php?id=' . htmlspecialchars($post['id']) . '" class="btn btn-sm btn-warning">Edit</a>
|
||||
<a href="delete.php?id=' . htmlspecialchars($post['id']) . '" class="btn btn-sm btn-danger" onclick="return confirm(\'Are you sure you want to delete this post?\');">Delete</a>
|
||||
</td>';
|
||||
echo "</tr>";
|
||||
}
|
||||
} else {
|
||||
echo '<tr><td colspan="5" class="text-center">No posts found.</td></tr>';
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo '<tr><td colspan="5" class="text-center text-danger">Error: ' . $e->getMessage() . '</td></tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
19
ai-and-tech.php
Normal file
19
ai-and-tech.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$pageTitle = 'AI & Tech Innovation';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
|
||||
<div class="text-center py-5">
|
||||
<h1 class="display-4">AI & Tech Innovation</h1>
|
||||
<p class="lead">Exploring the future of artificial intelligence and technology.</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card p-5 text-center">
|
||||
<p>This is the page for AI & Tech Innovation.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
131
assets/css/custom.css
Normal file
131
assets/css/custom.css
Normal file
@ -0,0 +1,131 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Poppins:wght@400;500&display=swap');
|
||||
|
||||
body {
|
||||
background-color: #fdfdfd;
|
||||
color: #333;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: 'Playfair Display', serif;
|
||||
font-weight: 700;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #007bff;
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #0056b3;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background-color: #fff;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-family: 'Playfair Display', serif;
|
||||
font-weight: 700;
|
||||
font-size: 1.75rem;
|
||||
color: #333 !important;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
font-size: 0.9rem;
|
||||
color: #555 !important;
|
||||
margin-left: 1.5rem;
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
color: #007bff !important;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 15px;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.07);
|
||||
overflow: hidden;
|
||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||
margin-bottom: 2.5rem;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 15px 35px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 2.5rem;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 2rem;
|
||||
margin-bottom: 1rem;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.card-text {
|
||||
color: #666;
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border-radius: 50px;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-weight: 500;
|
||||
padding: 0.8rem 2rem;
|
||||
font-size: 0.9rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #007bff;
|
||||
border-color: #007bff;
|
||||
color: #fff;
|
||||
box-shadow: 0 5px 15px rgba(0, 123, 255, 0.2);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: #0056b3;
|
||||
border-color: #0056b3;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 20px rgba(0, 123, 255, 0.3);
|
||||
}
|
||||
|
||||
.footer {
|
||||
background-color: #333;
|
||||
color: #fdfdfd;
|
||||
padding: 3rem 0;
|
||||
margin-top: 4rem;
|
||||
}
|
||||
|
||||
.footer a {
|
||||
color: #fdfdfd;
|
||||
}
|
||||
|
||||
.footer a:hover {
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1140px;
|
||||
}
|
||||
|
||||
.post-meta {
|
||||
font-size: 0.9rem;
|
||||
color: #888;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
19
automotives.php
Normal file
19
automotives.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$pageTitle = 'Automotives';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
|
||||
<div class="text-center py-5">
|
||||
<h1 class="display-4">Automotives</h1>
|
||||
<p class="lead">Latest news and insights from the automotive world.</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card p-5 text-center">
|
||||
<p>This is the page for Automotives.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
19
creative-and-tourism.php
Normal file
19
creative-and-tourism.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$pageTitle = 'Creative & Tourism';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
|
||||
<div class="text-center py-5">
|
||||
<h1 class="display-4">Creative & Tourism</h1>
|
||||
<p class="lead">Exploring the vibrant world of creativity and travel.</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card p-5 text-center">
|
||||
<p>This is the page for Creative & Tourism.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
@ -1,17 +1,26 @@
|
||||
<?php
|
||||
// Generated by setup_mariadb_project.sh — edit as needed.
|
||||
define('DB_HOST', '127.0.0.1');
|
||||
define('DB_NAME', 'app_36947');
|
||||
define('DB_USER', 'app_36947');
|
||||
define('DB_PASS', '6d1ce7e9-070c-4116-974a-cbbb781cce96');
|
||||
|
||||
function db() {
|
||||
static $pdo;
|
||||
if (!$pdo) {
|
||||
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
]);
|
||||
}
|
||||
return $pdo;
|
||||
}
|
||||
static $p;
|
||||
if ($p) return $p;
|
||||
|
||||
// Read credentials from environment variables
|
||||
$dbName = getenv('DB_NAME') ?: 'my_database';
|
||||
$dbHost = getenv('DB_HOST') ?: '127.0.0.1';
|
||||
$dbPort = getenv('DB_PORT') ?: '3306';
|
||||
$dbUser = getenv('DB_USER') ?: 'user';
|
||||
$dbPass = getenv('DB_PASS') ?: 'password';
|
||||
|
||||
$dsn = "mysql:host={$dbHost};port={$dbPort};dbname={$dbName};charset=utf8mb4";
|
||||
|
||||
try {
|
||||
$p = new PDO($dsn, $dbUser, $dbPass, [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
]);
|
||||
return $p;
|
||||
} catch (PDOException $e) {
|
||||
// In a real app, you'd log this error and show a generic message
|
||||
throw new PDOException($e->getMessage(), (int)$e->getCode());
|
||||
}
|
||||
}
|
||||
8
db/migrations/001_create_posts_table.sql
Normal file
8
db/migrations/001_create_posts_table.sql
Normal file
@ -0,0 +1,8 @@
|
||||
CREATE TABLE IF NOT EXISTS posts (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
author VARCHAR(255) NOT NULL,
|
||||
slug VARCHAR(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
6
db/migrations/002_create_users_table.sql
Normal file
6
db/migrations/002_create_users_table.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
username VARCHAR(50) NOT NULL UNIQUE,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
8
db/migrations/003_create_youtube_videos_table.sql
Normal file
8
db/migrations/003_create_youtube_videos_table.sql
Normal file
@ -0,0 +1,8 @@
|
||||
CREATE TABLE IF NOT EXISTS `youtube_videos` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`youtube_id` VARCHAR(255) NOT NULL UNIQUE,
|
||||
`title` VARCHAR(255) NOT NULL,
|
||||
`thumbnail_url` VARCHAR(255) NOT NULL,
|
||||
`published_at` DATETIME NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
26
db/setup.php
Normal file
26
db/setup.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/config.php';
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
|
||||
// Run migrations
|
||||
$migrations = glob(__DIR__ . '/migrations/*.sql');
|
||||
sort($migrations);
|
||||
foreach ($migrations as $migration) {
|
||||
$sql = file_get_contents($migration);
|
||||
$pdo->exec($sql);
|
||||
}
|
||||
|
||||
// Add a default admin user if one doesn't exist
|
||||
$stmt = $pdo->query("SELECT * FROM users WHERE username = 'admin'");
|
||||
if ($stmt->rowCount() == 0) {
|
||||
$username = 'admin';
|
||||
$password = password_hash('password', PASSWORD_DEFAULT);
|
||||
$pdo->prepare("INSERT INTO users (username, password) VALUES (?, ?)")->execute([$username, $password]);
|
||||
}
|
||||
|
||||
echo "Database setup and seeding successful.";
|
||||
} catch (PDOException $e) {
|
||||
die("Database setup failed: " . $e->getMessage());
|
||||
}
|
||||
25
delete.php
Normal file
25
delete.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
$post_id = $_GET['id'] ?? null;
|
||||
|
||||
if ($post_id) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("DELETE FROM posts WHERE id = ?");
|
||||
$stmt->execute([$post_id]);
|
||||
} catch (PDOException $e) {
|
||||
die("Error: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: admin.php');
|
||||
exit;
|
||||
?>
|
||||
79
edit.php
Normal file
79
edit.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$pageTitle = 'Edit Post';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
$post_id = $_GET['id'] ?? null;
|
||||
$message = '';
|
||||
$post = null;
|
||||
|
||||
if (!$post_id) {
|
||||
header('Location: admin.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT * FROM posts WHERE id = ?");
|
||||
$stmt->execute([$post_id]);
|
||||
$post = $stmt->fetch();
|
||||
} catch (PDOException $e) {
|
||||
$message = '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$title = $_POST['title'] ?? '';
|
||||
$content = $_POST['content'] ?? '';
|
||||
$author = $_POST['author'] ?? '';
|
||||
|
||||
if ($title && $content && $author) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("UPDATE posts SET title = ?, content = ?, author = ? WHERE id = ?");
|
||||
$stmt->execute([$title, $content, $author, $post_id]);
|
||||
header('Location: admin.php');
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
$message = '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
|
||||
}
|
||||
} else {
|
||||
$message = '<div class="alert alert-danger">Please fill in all fields.</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$post) {
|
||||
echo "<div class='alert alert-danger'>Post not found.</div>";
|
||||
require_once __DIR__ . '/includes/footer.php';
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<h1>Edit Post</h1>
|
||||
|
||||
<?php echo $message; ?>
|
||||
|
||||
<form method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label">Title</label>
|
||||
<input type="text" class="form-control" id="title" name="title" value="<?php echo htmlspecialchars($post['title']); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="author" class="form-label">Author</label>
|
||||
<input type="text" class="form-control" id="author" name="author" value="<?php echo htmlspecialchars($post['author']); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="content" class="form-label">Content</label>
|
||||
<textarea class="form-control" id="content" name="content" rows="10" required><?php echo htmlspecialchars($post['content']); ?></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Update Post</button>
|
||||
<a href="admin.php" class="btn btn-secondary">Cancel</a>
|
||||
</form>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php';
|
||||
11
includes/footer.php
Normal file
11
includes/footer.php
Normal file
@ -0,0 +1,11 @@
|
||||
</main>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="container text-center">
|
||||
<p>© <?php echo date('Y'); ?> <?php echo htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'My Blog'); ?>. All Rights Reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
37
includes/header.php
Normal file
37
includes/header.php
Normal file
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?php echo htmlspecialchars($pageTitle ?? 'My Blog'); ?></title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
<meta name="description" content="<?php echo htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'A clean blog to publish updates and articles.'); ?>">
|
||||
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
|
||||
<meta name="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="/"><?php echo htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'My Blog'); ?></a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/videos.php">Videos</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/automotives.php">Automotives</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/creative-and-tourism.php">Creative & Tourism</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/trade-and-industry.php">Trade & Industry</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/ai-and-tech.php">AI & Tech</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/skills-development.php">Skills Development</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/admin.php">Admin</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container">
|
||||
188
index.php
188
index.php
@ -1,150 +1,44 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
$pageTitle = 'Home';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->query("SELECT * FROM posts ORDER BY created_at DESC");
|
||||
$posts = $stmt->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
die("Error: " . $e->getMessage());
|
||||
}
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$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>
|
||||
|
||||
<div class="text-center py-5">
|
||||
<h1 class="display-4">Welcome to Our Blog</h1>
|
||||
<p class="lead">The latest news and updates, at your fingertips.</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<?php if (empty($posts)): ?>
|
||||
<div class="col-12">
|
||||
<div class="card p-5 text-center">
|
||||
<h2>No posts yet!</h2>
|
||||
<p>Go to the <a href="/admin.php">admin page</a> to create your first post.</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($posts as $post): ?>
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title"><?php echo htmlspecialchars($post['title']); ?></h2>
|
||||
<p class="post-meta">By <?php echo htmlspecialchars($post['author']); ?> on <?php echo date('F j, Y', strtotime($post['created_at'])); ?></p>
|
||||
<p class="card-text"><?php echo htmlspecialchars(substr($post['content'], 0, 250)); ?>...</p>
|
||||
<a href="/post.php?slug=<?php echo htmlspecialchars($post['slug']); ?>" class="btn btn-primary">Read More</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
|
||||
76
login.php
Normal file
76
login.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
// If user is already logged in, redirect to admin page
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
header('Location: admin.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$error = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
|
||||
if (empty($username) || empty($password)) {
|
||||
$error = 'Please enter both username and password.';
|
||||
} else {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->execute([$username]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
if ($user && password_verify($password, $user['password'])) {
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['username'] = $user['username'];
|
||||
header('Location: admin.php');
|
||||
exit;
|
||||
} else {
|
||||
$error = 'Invalid username or password.';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login</title>
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6 mt-5">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Admin Login
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger"><?php echo htmlspecialchars($error); ?></div>
|
||||
<?php endif; ?>
|
||||
<form method="POST">
|
||||
<div class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" name="username" id="username" class="form-control" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" name="password" id="password" class="form-control" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
7
logout.php
Normal file
7
logout.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_unset();
|
||||
session_destroy();
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
?>
|
||||
39
post.php
Normal file
39
post.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
$post = null;
|
||||
$slug = $_GET['slug'] ?? null;
|
||||
|
||||
if ($slug) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT * FROM posts WHERE slug = ?");
|
||||
$stmt->execute([$slug]);
|
||||
$post = $stmt->fetch();
|
||||
} catch (PDOException $e) {
|
||||
die("Error: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!$post) {
|
||||
http_response_code(404);
|
||||
$pageTitle = 'Post Not Found';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
echo "<h1>Post Not Found</h1><p>Sorry, the post you are looking for does not exist.</p>";
|
||||
require_once __DIR__ . '/includes/footer.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$pageTitle = $post['title'];
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
|
||||
<article>
|
||||
<h1><?php echo htmlspecialchars($post['title']); ?></h1>
|
||||
<p class="text-muted">By <?php echo htmlspecialchars($post['author']); ?> on <?php echo date('F j, Y', strtotime($post['created_at'])); ?></p>
|
||||
<div><?php echo nl2br(htmlspecialchars($post['content'])); ?></div>
|
||||
</article>
|
||||
|
||||
<a href="/" class="btn btn-primary mt-4">Back to Blog</a>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
19
skills-development.php
Normal file
19
skills-development.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$pageTitle = 'Skills Development';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
|
||||
<div class="text-center py-5">
|
||||
<h1 class="display-4">Skills Development</h1>
|
||||
<p class="lead">Empowering the workforce of tomorrow.</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card p-5 text-center">
|
||||
<p>This is the page for Skills Development.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
19
trade-and-industry.php
Normal file
19
trade-and-industry.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$pageTitle = 'Trade & Industry';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
|
||||
<div class="text-center py-5">
|
||||
<h1 class="display-4">Trade & Industry</h1>
|
||||
<p class="lead">The latest trends and developments in trade and industry.</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card p-5 text-center">
|
||||
<p>This is the page for Trade & Industry.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
30
videos.php
Normal file
30
videos.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
$pdo = db();
|
||||
$stmt = $pdo->query("SELECT * FROM youtube_videos ORDER BY published_at DESC");
|
||||
$videos = $stmt->fetchAll();
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
<h1 class="my-4">Latest Videos</h1>
|
||||
<div class="row">
|
||||
<?php foreach ($videos as $video): ?>
|
||||
<div class="col-lg-4 col-md-6 mb-4">
|
||||
<div class="card h-100">
|
||||
<a href="https://www.youtube.com/watch?v=<?php echo htmlspecialchars($video['youtube_id']); ?>" target="_blank">
|
||||
<img class="card-img-top" src="<?php echo htmlspecialchars($video['thumbnail_url']); ?>" alt="<?php echo htmlspecialchars($video['title']); ?>">
|
||||
</a>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
<a href="https://www.youtube.com/watch?v=<?php echo htmlspecialchars($video['youtube_id']); ?>" target="_blank"><?php echo htmlspecialchars($video['title']); ?></a>
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
40
youtube.php
Normal file
40
youtube.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
$channel_id = 'UCv4OxMyz0n-KQfATK3Tbexg';
|
||||
$rss_url = 'https://www.youtube.com/feeds/videos.xml?channel_id=' . $channel_id;
|
||||
|
||||
$xml_content = @file_get_contents($rss_url);
|
||||
|
||||
if ($xml_content === false) {
|
||||
die('Failed to fetch YouTube RSS feed. The channel ID might be incorrect or the channel may not have any videos.');
|
||||
}
|
||||
|
||||
$xml = new SimpleXMLElement($xml_content);
|
||||
|
||||
if (!isset($xml->entry)) {
|
||||
die('No video entries found in the RSS feed.');
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
$stmt = $pdo->prepare("INSERT IGNORE INTO youtube_videos (youtube_id, title, thumbnail_url, published_at) VALUES (:youtube_id, :title, :thumbnail_url, :published_at)");
|
||||
|
||||
foreach ($xml->entry as $entry) {
|
||||
$media = $entry->children('media', true);
|
||||
$yt = $entry->children('yt', true);
|
||||
|
||||
$video_id = (string)$yt->videoId;
|
||||
$title = (string)$media->group->title;
|
||||
$thumbnail_url = (string)$media->group->thumbnail->attributes()->url;
|
||||
$published_at = new DateTime((string)$entry->published);
|
||||
|
||||
$stmt->execute([
|
||||
':youtube_id' => $video_id,
|
||||
':title' => $title,
|
||||
':thumbnail_url' => $thumbnail_url,
|
||||
':published_at' => $published_at->format('Y-m-d H:i:s')
|
||||
]);
|
||||
}
|
||||
|
||||
echo "YouTube videos have been successfully imported.";
|
||||
Loading…
x
Reference in New Issue
Block a user