-
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) ?>
+
+
+
+
+
+
+
+
Build Your Community. Shape Your City.
+
The platform where neighbors connect, leaders emerge, and real change starts with one discussion.
+
Join Your City
+
Explore Communities
+
+
+
+
+
+
+
+
+
Connect
+
Join communities in your city and connect with your neighbors.
+
+
+
+
Discuss
+
Start and participate in discussions about topics that matter to you.
+
+
+
+
Organize
+
Create events and proposals to drive real change in your community.
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/login.php b/login.php
new file mode 100644
index 0000000..89ee94e
--- /dev/null
+++ b/login.php
@@ -0,0 +1,117 @@
+
+prepare('SELECT * FROM users WHERE email = ?');
+ $stmt->execute([$email]);
+ $user = $stmt->fetch();
+
+ if ($user && password_verify($password, $user['password'])) {
+ $_SESSION['user_id'] = $user['id'];
+ header('Location: communities.php');
+ exit;
+ } else {
+ $errors[] = 'Invalid email or password';
+ }
+ } catch (PDOException $e) {
+ $errors[] = 'Database error: ' . $e->getMessage();
+ }
+ }
+}
+?>
+
+
+
+
+
+
Login - Community Hub
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Login to Your Account
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/logout.php b/logout.php
new file mode 100644
index 0000000..215a7e2
--- /dev/null
+++ b/logout.php
@@ -0,0 +1,7 @@
+
+prepare('SELECT * FROM users WHERE id = ?');
+$stmt->execute([$user_id]);
+$user = $stmt->fetch();
+
+// Fetch user's communities
+$stmt = $pdo->prepare('SELECT c.* FROM communities c JOIN community_members cm ON c.id = cm.community_id WHERE cm.user_id = ?');
+$stmt->execute([$user_id]);
+$communities = $stmt->fetchAll();
+
+// Fetch user's discussions
+$stmt = $pdo->prepare('SELECT * FROM discussions WHERE user_id = ? ORDER BY created_at DESC');
+$stmt->execute([$user_id]);
+$discussions = $stmt->fetchAll();
+
+$name = $user['name'];
+$city = $user['city'];
+$errors = [];
+
+if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ $name = trim($_POST['name'] ?? '');
+ $city = trim($_POST['city'] ?? '');
+
+ if (empty($name)) {
+ $errors[] = 'Name is required';
+ }
+ if (empty($city)) {
+ $errors[] = 'City is required';
+ }
+
+ if (empty($errors)) {
+ try {
+ $stmt = $pdo->prepare('UPDATE users SET name = ?, city = ? WHERE id = ?');
+ $stmt->execute([$name, $city, $user_id]);
+ header('Location: profile.php');
+ exit;
+ } catch (PDOException $e) {
+ $errors[] = 'Database error: ' . $e->getMessage();
+ }
+ }
+}
+
+?>
+
+
+
+
+
+
Your Profile - Community Hub
+
+
+
+
+
+
+
+
+
+ Your Profile
+
+
+
+
+
Your Information
+
Name:
+
Email:
+
City:
+
Role:
+
+
+
+
+
+
+
+
Your Communities
+
+
+
You are not a member of any communities yet.
+
+
+
+
+
+
+
+
+
+
+
+
+
Your Discussions
+
+
+
You have not started any discussions yet.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/proposal.php b/proposal.php
new file mode 100644
index 0000000..170aace
--- /dev/null
+++ b/proposal.php
@@ -0,0 +1,152 @@
+
+prepare('SELECT p.*, u.name as user_name, c.name as community_name FROM proposals p JOIN users u ON p.user_id = u.id JOIN communities c ON p.community_id = c.id WHERE p.id = ?');
+$stmt->execute([$proposal_id]);
+$proposal = $stmt->fetch();
+
+if (!$proposal) {
+ header('Location: communities.php');
+ exit;
+}
+
+// Handle voting
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['vote'])) {
+ $vote = $_POST['vote'];
+ if (in_array($vote, ['up', 'down'])) {
+ try {
+ // Check if user has already voted
+ $stmt = $pdo->prepare('SELECT id FROM proposal_votes WHERE user_id = ? AND proposal_id = ?');
+ $stmt->execute([$user_id, $proposal_id]);
+ if ($stmt->fetch()) {
+ // Update existing vote
+ $stmt = $pdo->prepare('UPDATE proposal_votes SET vote = ? WHERE user_id = ? AND proposal_id = ?');
+ $stmt->execute([$vote, $user_id, $proposal_id]);
+ } else {
+ // Insert new vote
+ $stmt = $pdo->prepare('INSERT INTO proposal_votes (proposal_id, user_id, vote) VALUES (?, ?, ?)');
+ $stmt->execute([$proposal_id, $user_id, $vote]);
+ }
+ header('Location: proposal.php?id=' . $proposal_id);
+ exit;
+ } catch (PDOException $e) {
+ $errors[] = 'Database error: ' . $e->getMessage();
+ }
+ }
+}
+
+// Fetch votes
+$stmt = $pdo->prepare('SELECT vote, COUNT(*) as count FROM proposal_votes WHERE proposal_id = ? GROUP BY vote');
+$stmt->execute([$proposal_id]);
+$votes = $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
+
+$up_votes = $votes['up'] ?? 0;
+$down_votes = $votes['down'] ?? 0;
+
+// Check if the current user has voted
+$stmt = $pdo->prepare('SELECT vote FROM proposal_votes WHERE user_id = ? AND proposal_id = ?');
+$stmt->execute([$user_id, $proposal_id]);
+$user_vote = $stmt->fetchColumn();
+
+?>
+
+
+
+
+
+
- Community Hub
+
+
+
+
+
+
+
+
+
+
+
+ Voting
+
+
+ time()): ?>
+
+
+
Cast Your Vote
+
+
+
+
+
+ Voting on this proposal has ended.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/proposals.php b/proposals.php
new file mode 100644
index 0000000..d4daf32
--- /dev/null
+++ b/proposals.php
@@ -0,0 +1,161 @@
+
+prepare('SELECT * FROM communities WHERE id = ?');
+$stmt->execute([$community_id]);
+$community = $stmt->fetch();
+
+if (!$community) {
+ header('Location: communities.php');
+ exit;
+}
+
+// Fetch user role
+$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
+$stmt->execute([$user_id]);
+$user_role = $stmt->fetchColumn();
+
+// Handle new proposal form submission
+$title = $description = $end_time = '';
+$errors = [];
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && $user_role === 'leader') {
+ $title = trim($_POST['title'] ?? '');
+ $description = trim($_POST['description'] ?? '');
+ $end_time = trim($_POST['end_time'] ?? '');
+
+ if (empty($title)) {
+ $errors[] = 'Title is required';
+ }
+ if (empty($description)) {
+ $errors[] = 'Description is required');
+ }
+ if (empty($end_time)) {
+ $errors[] = 'End time is required';
+ }
+
+ if (empty($errors)) {
+ try {
+ $stmt = $pdo->prepare('INSERT INTO proposals (community_id, user_id, title, description, end_time) VALUES (?, ?, ?, ?, ?)');
+ $stmt->execute([$community_id, $user_id, $title, $description, $end_time]);
+ header('Location: proposals.php?community_id=' . $community_id);
+ exit;
+ } catch (PDOException $e) {
+ $errors[] = 'Database error: ' . $e->getMessage();
+ }
+ }
+}
+
+// Fetch proposals
+$stmt = $pdo->prepare('SELECT p.*, u.name as user_name FROM proposals p JOIN users u ON p.user_id = u.id WHERE p.community_id = ? ORDER BY p.created_at DESC');
+$stmt->execute([$community_id]);
+$proposals = $stmt->fetchAll();
+
+?>
+
+
+
+
+
+
Proposals - Community Hub
+
+
+
+
+
+
+
+
+
+ Proposals in
+
+
+
+
+
Create a New Proposal
+
+
+
+
+
+
+
+
+ Active Proposals
+
+
+
+
+
+
+
+
+
+
diff --git a/signup.php b/signup.php
new file mode 100644
index 0000000..f910cff
--- /dev/null
+++ b/signup.php
@@ -0,0 +1,188 @@
+
+prepare('SELECT id FROM users WHERE email = ?');
+ $stmt->execute([$email]);
+ if ($stmt->fetch()) {
+ $errors[] = 'User with this email already exists';
+ } else {
+ $pdo->beginTransaction();
+
+ // Check if community for the city exists
+ $stmt = $pdo->prepare('SELECT id FROM communities WHERE name = ?');
+ $stmt->execute([$city]);
+ $community = $stmt->fetch();
+
+ $role = 'member';
+ if (!$community) {
+ $role = 'leader';
+ }
+
+ // Insert the new user
+ $hashed_password = password_hash($password, PASSWORD_DEFAULT);
+ $stmt = $pdo->prepare('INSERT INTO users (name, email, password, city, role) VALUES (?, ?, ?, ?, ?)');
+ $stmt->execute([$name, $email, $hashed_password, $city, $role]);
+ $user_id = $pdo->lastInsertId();
+
+ if ($role === 'leader') {
+ $stmt = $pdo->prepare('INSERT INTO communities (name, leader_id) VALUES (?, ?)');
+ $stmt->execute([$city, $user_id]);
+ $community_id = $pdo->lastInsertId();
+ } else {
+ $community_id = $community['id'];
+ }
+
+ // Add user to community
+ $stmt = $pdo->prepare('INSERT INTO community_members (user_id, community_id) VALUES (?, ?)');
+ $stmt->execute([$user_id, $community_id]);
+
+ $pdo->commit();
+
+ $_SESSION['user_id'] = $user_id;
+ header('Location: communities.php');
+ exit;
+ }
+ } catch (PDOException $e) {
+ if ($pdo->inTransaction()) {
+ $pdo->rollBack();
+ }
+ $errors[] = 'Database error: ' . $e->getMessage();
+ }
+ }
+}
+?>
+
+
+
+
+
+
Sign Up - Community Hub
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file