-
Analyzing your requirements and generating your website…
-
- Loading…
-
-
= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.
-
This page will update automatically as the plan is implemented.
-
Runtime: PHP = htmlspecialchars($phpVersion) ?> — UTC = htmlspecialchars($now) ?>
+
+query("SELECT * FROM categories WHERE visibility = 1 ORDER BY display_order ASC, name ASC");
+$categories = $stmt->fetchAll();
+
+// Determine the current category
+$current_category_id = null;
+$current_category_name = 'All Categories';
+if (isset($_GET['category']) && filter_var($_GET['category'], FILTER_VALIDATE_INT)) {
+ $category_id_from_get = (int)$_GET['category'];
+ $stmt = $pdo->prepare("SELECT id, name FROM categories WHERE id = ? AND visibility = 1");
+ $stmt->execute([$category_id_from_get]);
+ $cat = $stmt->fetch();
+ if ($cat) {
+ $current_category_id = $cat['id'];
+ $current_category_name = $cat['name'];
+ }
+}
+
+// Fetch links for the current category
+$link_stmt = null;
+if ($current_category_id) {
+ $link_stmt = $pdo->prepare(
+ "SELECT l.*, s.name as subcategory_name FROM links l " .
+ "JOIN subcategories s ON l.subcategory_id = s.id " .
+ "WHERE s.category_id = ? AND l.status = \'approved\' ORDER BY s.name ASC, l.created_at DESC"
+ );
+ $link_stmt->execute([$current_category_id]);
+} else {
+ $link_stmt = $pdo->query(
+ "SELECT l.*, s.name as subcategory_name, c.name as category_name " .
+ "FROM links l " .
+ "JOIN subcategories s ON l.subcategory_id = s.id " .
+ "JOIN categories c ON s.category_id = c.id " .
+ "WHERE l.status = 'approved' " .
+ "ORDER BY c.name ASC, s.name ASC, l.created_at DESC"
+ );
+}
+$current_links = $link_stmt->fetchAll();
+
+error_log("DEBUG: GET Parameters: " . json_encode($_GET));
+error_log("DEBUG: Current Category ID: " . ($current_category_id ?? "NULL"));
+error_log("DEBUG: Current Category Name: " . $current_category_name);
+error_log("DEBUG: SQL Query for links: " . ($current_category_id ? $link_stmt->queryString : "All Categories Query"));
+error_log("DEBUG: Current Links Count: " . count($current_links));
+
+
+
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No links found in this category yet.
+
+ ' . htmlspecialchars($current_category_for_display) . '';
+ $current_subcategory = null; // Reset subcategory when category changes
+ }
+
+ if ($link['subcategory_name'] !== $current_subcategory) {
+ $current_subcategory = $link['subcategory_name'];
+ echo '' . htmlspecialchars($current_subcategory) . '
';
+ }
+ ?>
+
+
![Thumbnail for <?php echo htmlspecialchars($link['title']); ?>](<?php echo htmlspecialchars($link['thumbnail']); ?>)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/login.php b/login.php
new file mode 100644
index 0000000..638e8a5
--- /dev/null
+++ b/login.php
@@ -0,0 +1,100 @@
+prepare("SELECT id, username, password, role 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'];
+ $_SESSION['user_role'] = $user['role'];
+ header("Location: index.php");
+ exit;
+ } else {
+ $errors[] = 'Invalid username or password.';
+ }
+ } catch (PDOException $e) {
+ $errors[] = "Database error: " . $e->getMessage();
+ }
+ }
+}
+?>
+
+
+
+
+
+
Login -
+
+
+
+
+
+
+
+
+
+
+
+ Login
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/logout.php b/logout.php
new file mode 100644
index 0000000..f83284d
--- /dev/null
+++ b/logout.php
@@ -0,0 +1,6 @@
+prepare("SELECT id FROM users WHERE username = ?");
+ $stmt->execute([$username]);
+ if ($stmt->fetch()) {
+ $errors[] = 'Username already taken.';
+ } else {
+ $hashed_password = password_hash($password, PASSWORD_DEFAULT);
+ $stmt = $pdo->prepare("INSERT INTO users (username, password, role) VALUES (?, ?, ?)");
+ // For now, all new users are 'regular'. The first admin will be created manually.
+ $stmt->execute([$username, $hashed_password, 'regular']);
+ $success = true;
+ }
+ } catch (PDOException $e) {
+ $errors[] = "Database error: " . $e->getMessage();
+ }
+ }
+}
+?>
+
+
+
+
+
+
Register -
+
+
+
+
+
+
+
+
+
+
+
+ Register
+
+
+
+
+
+
+
+
Registration successful! You can now login.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/submit.php b/submit.php
new file mode 100644
index 0000000..aae7963
--- /dev/null
+++ b/submit.php
@@ -0,0 +1,160 @@
+query("SELECT * FROM categories WHERE visibility = 1 ORDER BY display_order ASC, name ASC")->fetchAll();
+$subcategories = [];
+if (!empty($categories)) {
+ $stmt = $pdo->query("SELECT * FROM subcategories ORDER BY name ASC");
+ while ($row = $stmt->fetch()) {
+ $subcategories[$row['category_id']][] = $row;
+ }
+}
+
+if ($_SERVER["REQUEST_METHOD"] == "POST") {
+ $title = trim($_POST['title'] ?? '');
+ $url = trim($_POST['url'] ?? '');
+ $description = trim($_POST['description'] ?? '');
+ $subcategory_id = $_POST['subcategory_id'] ?? null;
+
+ if (empty($title)) $errors[] = 'Title is required.';
+ if (empty($url)) $errors[] = 'URL is required.';
+ if (!filter_var($url, FILTER_VALIDATE_URL)) $errors[] = 'Invalid URL.';
+ if (empty($subcategory_id)) $errors[] = 'Subcategory is required.';
+
+ if (empty($errors)) {
+ // Determine status based on user role
+ $status = ($_SESSION['user_role'] === 'admin' || $_SESSION['user_role'] === 'power_user') ? 'approved' : 'pending';
+
+ // For now, thumbnail is not implemented
+ $thumbnail_url = null;
+
+ try {
+ $stmt = $pdo->prepare("INSERT INTO links (user_id, subcategory_id, title, url, description, thumbnail_url, status) VALUES (?, ?, ?, ?, ?, ?, ?)");
+ $stmt->execute([$_SESSION['user_id'], $subcategory_id, $title, $url, $description, $thumbnail_url, $status]);
+ $success = true;
+ } catch (PDOException $e) {
+ $errors[] = "Database error: " . $e->getMessage();
+ }
+ }
+}
+?>
+
+
+
+
+
+
Submit a Link -
+
+
+
+
+
+
+
+
+
+
+
+ Submit a New Link
+
+
+
+
+
+
+
+
Thank you for your submission! It will be reviewed shortly.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+