v4
This commit is contained in:
parent
f3fecfd7d2
commit
27c6849991
@ -1,122 +1,250 @@
|
||||
|
||||
body {
|
||||
background-color: #121212;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill='%231a1a1a' fill-opacity='0.4'%3E%3Crect x='0' y='0' width='100' height='1'/%3E%3Crect x='0' y='0' width='1' height='100'/%3E%3C/g%3E%3C/svg%3E");
|
||||
color: #FFFFFF;
|
||||
background-color: #0d1117;
|
||||
color: #c9d1d9;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
.card-neon {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
.navbar {
|
||||
background-color: rgba(13, 17, 23, 0.8);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
|
||||
transition: background 0.3s ease, box-shadow 0.3s ease;
|
||||
}
|
||||
|
||||
.card-neon:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
|
||||
.nav-link {
|
||||
color: #c9d1d9;
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
|
||||
/* Typography */
|
||||
h1, h2, h3, h4, h5 {
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2.25rem;
|
||||
}
|
||||
|
||||
/* Animations */
|
||||
.card-neon {
|
||||
animation: fadeIn 0.5s ease-in-out;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-primary:hover,
|
||||
.btn-secondary:hover,
|
||||
.list-group-item-action:hover {
|
||||
transform: translateY(-3px);
|
||||
transition: transform 0.3s ease;
|
||||
.nav-link:hover, .nav-link.active {
|
||||
color: #58a6ff;
|
||||
}
|
||||
|
||||
.hero {
|
||||
background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('https://images.pexels.com/photos/159888/pexels-photo-159888.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1');
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
color: white;
|
||||
padding: 100px 0;
|
||||
background: radial-gradient(ellipse at bottom, #1f6feb 0%, #0d1117 80%);
|
||||
padding: 120px 0;
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #30363d;
|
||||
}
|
||||
|
||||
.hero h1 {
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-weight: 700;
|
||||
font-size: 3.5rem;
|
||||
font-size: 3.8rem;
|
||||
color: #ffffff;
|
||||
text-shadow: 0 2px 4px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.hero p {
|
||||
font-size: 1.25rem;
|
||||
margin-bottom: 30px;
|
||||
font-size: 1.2rem;
|
||||
color: #c9d1d9;
|
||||
max-width: 600px;
|
||||
margin: 0 auto 30px;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: linear-gradient(45deg, #FF4B2B, #FF416C);
|
||||
border: none;
|
||||
padding: 15px 30px;
|
||||
font-size: 1.2rem;
|
||||
background-color: #238636;
|
||||
border-color: #238636;
|
||||
padding: 12px 28px;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
transition: transform 0.3s ease;
|
||||
transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
transform: translateY(-3px);
|
||||
background-color: #2ea043;
|
||||
border-color: #2ea043;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: transparent;
|
||||
border: 2px solid white;
|
||||
padding: 15px 30px;
|
||||
font-size: 1.2rem;
|
||||
border: 1px solid #30363d;
|
||||
color: #58a6ff;
|
||||
padding: 12px 28px;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
color: white;
|
||||
transition: background-color 0.3s ease, color 0.3s ease;
|
||||
transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background-color: white;
|
||||
color: #121212;
|
||||
background-color: #58a6ff;
|
||||
border-color: #58a6ff;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.features {
|
||||
padding: 80px 0;
|
||||
padding: 100px 0;
|
||||
background-color: #0d1117;
|
||||
}
|
||||
|
||||
.feature-icon {
|
||||
font-size: 3rem;
|
||||
color: #FF4B2B;
|
||||
font-size: 2.5rem;
|
||||
color: #58a6ff;
|
||||
margin-bottom: 1.5rem;
|
||||
display: inline-block;
|
||||
padding: 1rem;
|
||||
background-color: rgba(31, 111, 235, 0.1);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.features h3 {
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-weight: 600;
|
||||
color: #f0f6fc;
|
||||
}
|
||||
|
||||
.features p {
|
||||
color: #8b949e;
|
||||
}
|
||||
|
||||
.footer {
|
||||
background-color: #1E1E1E;
|
||||
background-color: #161b22;
|
||||
padding: 40px 0;
|
||||
color: #A0A0A0;
|
||||
color: #8b949e;
|
||||
border-top: 1px solid #30363d;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5 {
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-weight: 600;
|
||||
color: #f0f6fc;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
background-color: rgba(22, 27, 34, 0.8);
|
||||
padding: 2.5rem;
|
||||
border-radius: 1rem;
|
||||
border: 1px solid #30363d;
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.form-container .form-label {
|
||||
color: #c9d1d9;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.form-container .form-control {
|
||||
background-color: #0d1117;
|
||||
color: #c9d1d9;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.form-container .form-control:focus {
|
||||
background-color: #161b22;
|
||||
color: #c9d1d9;
|
||||
border-color: #58a6ff;
|
||||
box-shadow: 0 0 0 0.25rem rgba(88, 166, 255, 0.25);
|
||||
}
|
||||
|
||||
.form-container .btn-primary {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.discussion-card {
|
||||
background-color: #161b22;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 0.5rem;
|
||||
padding: 1.5rem;
|
||||
margin-bottom: 1rem;
|
||||
transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.discussion-card:hover {
|
||||
background-color: #1f242c;
|
||||
border-color: #58a6ff;
|
||||
}
|
||||
|
||||
.discussion-card a {
|
||||
color: #f0f6fc;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.discussion-card a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.pagination .page-item .page-link {
|
||||
background-color: #161b22;
|
||||
border-color: #30363d;
|
||||
color: #58a6ff;
|
||||
}
|
||||
|
||||
.pagination .page-item.active .page-link {
|
||||
background-color: #58a6ff;
|
||||
border-color: #58a6ff;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.pagination .page-item.disabled .page-link {
|
||||
background-color: #161b22;
|
||||
border-color: #30363d;
|
||||
color: #484f58;
|
||||
}
|
||||
|
||||
.discussion-post {
|
||||
background-color: #161b22;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 0.5rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.discussion-post .card-header {
|
||||
background-color: rgba(31, 111, 235, 0.1);
|
||||
border-bottom: 1px solid #30363d;
|
||||
}
|
||||
|
||||
.discussion-post .card-body {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.reply-card {
|
||||
background-color: #0d1117;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 0.5rem;
|
||||
padding: 1.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.reply-card .reply-header {
|
||||
font-size: 0.9rem;
|
||||
color: #8b949e;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.profile-container {
|
||||
background-color: #161b22;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 1rem;
|
||||
padding: 3rem;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.profile-avatar {
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
border-radius: 50%;
|
||||
border: 3px solid #58a6ff;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.profile-details p {
|
||||
font-size: 1.1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.profile-details p strong {
|
||||
color: #8b949e;
|
||||
width: 100px;
|
||||
display: inline-block;
|
||||
}
|
||||
18
assets/js/city-finder.js
Normal file
18
assets/js/city-finder.js
Normal file
@ -0,0 +1,18 @@
|
||||
function getCity() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(position => {
|
||||
const lat = position.coords.latitude;
|
||||
const lon = position.coords.longitude;
|
||||
// Using a free reverse geocoding API
|
||||
fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lon}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.address && data.address.city) {
|
||||
document.getElementById('city').value = data.address.city;
|
||||
}
|
||||
})
|
||||
.catch(err => console.error("Error fetching city:", err));
|
||||
});
|
||||
}
|
||||
}
|
||||
window.onload = getCity;
|
||||
@ -0,0 +1,97 @@
|
||||
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Fetch user role if logged in
|
||||
$user_role = null;
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->query('SELECT * FROM communities ORDER BY name');
|
||||
$communities = $stmt->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
$error_message = "Error fetching communities: " . $e->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Communities - Community Hub</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&family=Roboto:wght@400;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</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="index.php">Home</a></li>
|
||||
<?php if (isset($_SESSION['user_id'])): ?>
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="communities.php">Communities</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
|
||||
<?php else: ?>
|
||||
<li class="nav-item"><a class="nav-link" href="login.php">Login</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="signup.php">Sign Up</a></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="flex-grow-1">
|
||||
<div class="container py-5">
|
||||
<h1 class="text-center mb-5">Explore Communities</h1>
|
||||
|
||||
<?php if (!empty($error_message)): ?>
|
||||
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
||||
<?php elseif (empty($communities)): ?>
|
||||
<div class="text-center">
|
||||
<p>No communities found. Be the first to create one!</p>
|
||||
<a href="signup.php" class="btn btn-primary">Get Started</a>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="row gy-4">
|
||||
<?php foreach ($communities as $community): ?>
|
||||
<div class="col-md-6 col-lg-4">
|
||||
<div class="card h-100" style="background-color: #161b22; border-color: #30363d;">
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h5 class="card-title" style="color: #f0f6fc;"><?php echo htmlspecialchars($community['name']); ?></h5>
|
||||
<p class="card-text flex-grow-1" style="color: #8b949e;">A place for residents of <?php echo htmlspecialchars($community['name']); ?> to connect and organize.</p>
|
||||
<a href="discussions.php?community_id=<?php echo $community['id']; ?>" class="btn btn-secondary mt-auto">View Discussions</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="footer text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
110
conversation.php
110
conversation.php
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$with_id = $_GET['with'] ?? null;
|
||||
|
||||
if (!$with_id) {
|
||||
header('Location: messages.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch user role
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
// Fetch the other user's info
|
||||
$stmt = $pdo->prepare("SELECT username FROM users WHERE id = ?");
|
||||
$stmt->execute([$with_id]);
|
||||
$with_user = $stmt->fetch();
|
||||
|
||||
// Fetch conversation
|
||||
$stmt = $pdo->prepare("SELECT m.*, u.username as sender_username FROM messages m JOIN users u ON m.sender_id = u.id WHERE (m.sender_id = ? AND m.receiver_id = ?) OR (m.sender_id = ? AND m.receiver_id = ?) ORDER BY m.created_at ASC");
|
||||
$stmt->execute([$user_id, $with_id, $with_id, $user_id]);
|
||||
$messages = $stmt->fetchAll();
|
||||
|
||||
// Handle new message
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['message'])) {
|
||||
$message = $_POST['message'];
|
||||
$stmt = $pdo->prepare("INSERT INTO messages (sender_id, receiver_id, message) VALUES (?, ?, ?)");
|
||||
$stmt->execute([$user_id, $with_id, $message]);
|
||||
header("Location: conversation.php?with=$with_id");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Conversation with <?php echo htmlspecialchars($with_user['username']); ?></title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</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="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container mt-4 flex-grow-1">
|
||||
<h3>Conversation with <?php echo htmlspecialchars($with_user['username']); ?></h3>
|
||||
<div class="card">
|
||||
<div class="card-body" style="height: 400px; overflow-y: scroll;">
|
||||
<?php foreach ($messages as $msg): ?>
|
||||
<div class="d-flex <?php echo $msg['sender_id'] == $user_id ? 'justify-content-end' : ''; ?> mb-3">
|
||||
<div class="card <?php echo $msg['sender_id'] == $user_id ? 'bg-primary text-white' : 'bg-light'; ?>" style="max-width: 70%;">
|
||||
<div class="card-body">
|
||||
<p class="card-text"><?php echo htmlspecialchars($msg['message']); ?></p>
|
||||
<small class="text-muted d-block text-end"><?php echo date('M j, Y, g:i a', strtotime($msg['created_at'])); ?></small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<form method="POST">
|
||||
<div class="input-group">
|
||||
<input type="text" name="message" class="form-control" placeholder="Type your message...">
|
||||
<button type="submit" class="btn btn-primary">Send</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
83
create_proposal.php
Normal file
83
create_proposal.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
|
||||
// Fetch user role
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$user_id]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['title']) && !empty($_POST['description'])) {
|
||||
$title = $_POST['title'];
|
||||
$description = $_POST['description'];
|
||||
|
||||
$stmt = $pdo->prepare("INSERT INTO proposals (user_id, title, description) VALUES (?, ?, ?)");
|
||||
$stmt->execute([$user_id, $title, $description]);
|
||||
|
||||
header("Location: proposals.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>New Proposal</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</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="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container mt-4 flex-grow-1">
|
||||
<h2>Create New Proposal</h2>
|
||||
<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="description" class="form-label">Description</label>
|
||||
<textarea class="form-control" id="description" name="description" rows="5" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit Proposal</button>
|
||||
</form>
|
||||
</main>
|
||||
|
||||
<footer class="bg-.dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -123,7 +123,9 @@ $replies = $stmt->fetchAll();
|
||||
<h2>Replies</h2>
|
||||
<div class="mb-4">
|
||||
<?php if (empty($replies)): ?>
|
||||
<p>No replies yet. Be the first to reply!</p>
|
||||
<div class="text-center p-4" style="background-color: #161b22; border-radius: 0.5rem;">
|
||||
<p class="mb-0">No replies yet. Be the first to reply!</p>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($replies as $reply): ?>
|
||||
<div class="card card-neon mb-3">
|
||||
|
||||
@ -111,7 +111,7 @@ $discussions = $stmt->fetchAll();
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<nav class="navbar navbar-expand-lg navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</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">
|
||||
@ -133,59 +133,62 @@ $discussions = $stmt->fetchAll();
|
||||
</nav>
|
||||
|
||||
<main class="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<h1 class="text-center mb-4">Discussions in <?php echo htmlspecialchars($community['name']); ?></h1>
|
||||
<div class="container py-5">
|
||||
<h1 class="text-center mb-5">Discussions in <?php echo htmlspecialchars($community['name']); ?></h1>
|
||||
|
||||
<div class="card card-neon mb-4">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Start a New Discussion</h2>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="discussions.php?community_id=<?php echo $community_id; ?>" 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($title); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="content" class="form-label">Content</label>
|
||||
<textarea class="form-control" id="content" name="content" rows="3" required><?php echo htmlspecialchars($content); ?></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-gradient">Post Discussion</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="form-container mb-5">
|
||||
<h2 class="mb-4">Start a New Discussion</h2>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p class="mb-0"><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="discussions.php?community_id=<?php echo $community_id; ?>" 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($title); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="content" class="form-label">Content</label>
|
||||
<textarea class="form-control" id="content" name="content" rows="4" required><?php echo htmlspecialchars($content); ?></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Post Discussion</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h2 class="mb-3">Existing Discussions</h2>
|
||||
<h2 class="mb-4">Existing Discussions</h2>
|
||||
|
||||
<form action="discussions.php" method="GET" class="mb-4">
|
||||
<input type="hidden" name="community_id" value="<?php echo $community_id; ?>">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="Search discussions..." name="search" value="<?php echo htmlspecialchars($search); ?>">
|
||||
<button class="btn btn-outline-secondary" type="submit">Search</button>
|
||||
<input type="text" class="form-control" placeholder="Search discussions..." name="search" value="<?php echo htmlspecialchars($search); ?>" style="background-color: #0d1117; color: #c9d1d9; border-color: #30363d;">
|
||||
<button class="btn btn-outline-secondary" type="submit" style="border-color: #30363d; color: #58a6ff;">Search</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="list-group">
|
||||
<div>
|
||||
<?php if (empty($discussions)): ?>
|
||||
<p>No discussions found.</p>
|
||||
<div class="text-center p-4" style="background-color: #161b22; border-radius: 0.5rem;">
|
||||
<p class="mb-0">No discussions found. Be the first to start one!</p>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($discussions as $discussion): ?>
|
||||
<a href="discussion.php?id=<?php echo $discussion['id']; ?>" class="list-group-item list-group-item-action">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1"><?php echo htmlspecialchars($discussion['title']); ?></h5>
|
||||
<small><?php echo date('M j, Y, g:i a', strtotime($discussion['created_at'])); ?></small>
|
||||
<div class="discussion-card">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<h5 class="mb-0">
|
||||
<a href="discussion.php?id=<?php echo $discussion['id']; ?>"><?php echo htmlspecialchars($discussion['title']); ?></a>
|
||||
</h5>
|
||||
<small class="text-muted"><?php echo date('M j, Y, g:i a', strtotime($discussion['created_at'])); ?></small>
|
||||
</div>
|
||||
<p class="mb-1">Started by: <?php echo htmlspecialchars($discussion['user_name']); ?></p>
|
||||
</a>
|
||||
<p class="mb-1 text-muted">Started by: <?php echo htmlspecialchars($discussion['user_name']); ?></p>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($total_pages > 1): ?>
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination justify-content-center mt-4">
|
||||
<li class="page-item <?php echo ($page <= 1) ? 'disabled' : ''; ?>">
|
||||
@ -201,10 +204,11 @@ $discussions = $stmt->fetchAll();
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<footer class="footer text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
|
||||
16
index.php
16
index.php
@ -24,7 +24,7 @@ if (isset($_SESSION['user_id'])) {
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<nav class="navbar navbar-expand-lg navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</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">
|
||||
@ -55,7 +55,7 @@ if (isset($_SESSION['user_id'])) {
|
||||
<div class="container">
|
||||
<h1 class="display-4">Build Your Community. Shape Your City.</h1>
|
||||
<p class="lead">The platform where neighbors connect, leaders emerge, and real change starts with one discussion.</p>
|
||||
<a href="signup.php" class="btn btn-primary btn-gradient me-2">Join Your City</a>
|
||||
<a href="signup.php" class="btn btn-primary me-2">Join Your City</a>
|
||||
<a href="communities.php" class="btn btn-secondary">Explore Communities</a>
|
||||
</div>
|
||||
</header>
|
||||
@ -68,28 +68,28 @@ if (isset($_SESSION['user_id'])) {
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-users"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>
|
||||
</div>
|
||||
<h3>Connect</h3>
|
||||
<p class="text-muted">Join communities in your city and connect with your neighbors.</p>
|
||||
<p>Join communities in your city and connect with your neighbors.</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="feature-icon mb-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-message-square"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-message-circle"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></svg>
|
||||
</div>
|
||||
<h3>Discuss</h3>
|
||||
<p class="text-muted">Start and participate in discussions about topics that matter to you.</p>
|
||||
<p>Start and participate in discussions about topics that matter to you.</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="feature-icon mb-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-trending-up"><polyline points="23 6 13.5 15.5 8.5 10.5 1 18"></polyline><polyline points="17 6 23 6 23 12"></polyline></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-calendar"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>
|
||||
</div>
|
||||
<h3>Organize</h3>
|
||||
<p class="text-muted">Create events and proposals to drive real change in your community.</p>
|
||||
<p>Create events and proposals to drive real change in your community.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<footer class="footer text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
|
||||
60
login.php
60
login.php
@ -48,8 +48,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<nav class="navbar navbar-expand-lg navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</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">
|
||||
@ -72,42 +71,39 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
<main class="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<main class="flex-grow-1 d-flex align-items-center justify-content-center">
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card card-neon">
|
||||
<div class="card-body">
|
||||
<h1 class="text-center mb-4">Login to Your Account</h1>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="login.php" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email address</label>
|
||||
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
</div>
|
||||
<div class="d-grid">
|
||||
<button type="submit" class="btn btn-primary btn-gradient">Login</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-6 col-lg-5">
|
||||
<div class="form-container">
|
||||
<h1 class="text-center mb-4">Login to Your Account</h1>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p class="mb-0"><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="login.php" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email address</label>
|
||||
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" required>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
</div>
|
||||
<div class="d-grid">
|
||||
<button type="submit" class="btn btn-primary">Login</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<footer class="footer text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
|
||||
89
messages.php
89
messages.php
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch conversations
|
||||
$stmt = $pdo->prepare("SELECT u.id as user_id, u.username, m.message, m.created_at
|
||||
FROM messages m
|
||||
JOIN users u ON u.id = m.sender_id OR u.id = m.receiver_id
|
||||
WHERE (m.sender_id = :user_id OR m.receiver_id = :user_id)
|
||||
AND u.id != :user_id
|
||||
AND m.id IN (
|
||||
SELECT MAX(id) FROM messages
|
||||
WHERE sender_id = :user_id OR receiver_id = :user_id
|
||||
GROUP BY LEAST(sender_id, receiver_id), GREATEST(sender_id, receiver_id)
|
||||
)
|
||||
ORDER BY m.created_at DESC");
|
||||
|
||||
$stmt->execute(['user_id' => $user_id]);
|
||||
$conversations = $stmt->fetchAll();
|
||||
|
||||
// Fetch user role
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Messages</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</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="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container mt-4 flex-grow-1">
|
||||
<h2>Messages</h2>
|
||||
<div class="list-group">
|
||||
<?php foreach ($conversations as $convo): ?>
|
||||
<a href="conversation.php?with=<?php echo $convo['user_id']; ?>" class="list-group-item list-group-item-action">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1"><?php echo htmlspecialchars($convo['username']); ?></h5>
|
||||
<small><?php echo date('M j, Y, g:i a', strtotime($convo['created_at'])); ?></small>
|
||||
</div>
|
||||
<p class="mb-1"><?php echo htmlspecialchars(substr($convo['message'], 0, 100)); ?>...</p>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
77
profile.php
77
profile.php
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch user data
|
||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
|
||||
$stmt->execute([$user_id]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
// Fetch user role
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>My Profile - Community Hub</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</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="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="flex-grow-1">
|
||||
<div class="container">
|
||||
<div class="profile-container text-center">
|
||||
<img src="https://i.pravatar.cc/150?u=<?php echo $user_id; ?>" alt="User Avatar" class="profile-avatar">
|
||||
<h1 class="mb-4"><?php echo htmlspecialchars($user['name']); ?></h1>
|
||||
<div class="profile-details text-start mx-auto" style="max-width: 400px;">
|
||||
<p><strong>Email:</strong> <?php echo htmlspecialchars($user['email']); ?></p>
|
||||
<p><strong>City:</strong> <?php echo htmlspecialchars($user['city']); ?></p>
|
||||
<p><strong>Role:</strong> <span class="badge bg-primary"><?php echo htmlspecialchars(ucfirst($user['role'])); ?></span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="footer text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
88
proposal.php
88
proposal.php
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$proposal_id = $_GET['id'] ?? null;
|
||||
|
||||
if (!$proposal_id) {
|
||||
// Redirect or show an error if no proposal ID is provided
|
||||
header('Location: proposals.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch proposal data
|
||||
$stmt = $pdo->prepare("SELECT p.*, u.username FROM proposals p JOIN users u ON p.user_id = u.id WHERE p.id = ?");
|
||||
$stmt->execute([$proposal_id]);
|
||||
$proposal = $stmt->fetch();
|
||||
|
||||
if (!$proposal) {
|
||||
// Redirect or show an error if proposal not found
|
||||
header('Location: proposals.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Fetch user role
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Proposal Details</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</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="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container mt-4 flex-grow-1">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2><?php echo htmlspecialchars($proposal['title']); ?></h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="card-text"><?php echo nl2br(htmlspecialchars($proposal['description'])); ?></p>
|
||||
<p><strong>Author:</strong> <?php echo htmlspecialchars($proposal['username']); ?></p>
|
||||
<p><strong>Status:</strong> <?php echo htmlspecialchars($proposal['status']); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch all proposals
|
||||
$stmt = $pdo->query("SELECT p.*, u.username FROM proposals p JOIN users u ON p.user_id = u.id ORDER BY p.created_at DESC");
|
||||
$proposals = $stmt->fetchAll();
|
||||
|
||||
// Fetch user role
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Proposals</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</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="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container mt-4 flex-grow-1">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h2>Proposals</h2>
|
||||
<a href="create_proposal.php" class="btn btn-primary">New Proposal</a>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<?php foreach ($proposals as $proposal): ?>
|
||||
<a href="proposal.php?id=<?php echo $proposal['id']; ?>" class="list-group-item list-group-item-action">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1"><?php echo htmlspecialchars($proposal['title']); ?></h5>
|
||||
<small><?php echo date('M j, Y', strtotime($proposal['created_at'])); ?></small>
|
||||
</div>
|
||||
<p class="mb-1"><?php echo htmlspecialchars(substr($proposal['description'], 0, 100)); ?>...</p>
|
||||
<small>By <?php echo htmlspecialchars($proposal['username']); ?></small>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
98
signup.php
98
signup.php
@ -89,10 +89,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<nav class="navbar navbar-expand-lg navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</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">
|
||||
@ -115,74 +115,52 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
<main class="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<main class="flex-grow-1 d-flex align-items-center justify-content-center">
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card card-neon">
|
||||
<div class="card-body">
|
||||
<h1 class="text-center mb-4">Create Your Account</h1>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="signup.php" method="POST" id="signup-form">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Full Name</label>
|
||||
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email address</label>
|
||||
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="city" class="form-label">City</label>
|
||||
<input type="text" class="form-control" id="city" name="city" value="<?php echo htmlspecialchars($city); ?>" required>
|
||||
</div>
|
||||
<div class="d-grid">
|
||||
<button type="submit" class="btn btn-primary btn-gradient">Sign Up</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-6 col-lg-5">
|
||||
<div class="form-container">
|
||||
<h1 class="text-center mb-4">Create Your Account</h1>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p class="mb-0"><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="signup.php" method="POST" id="signup-form">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Full Name</label>
|
||||
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email address</label>
|
||||
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="city" class="form-label">City</label>
|
||||
<input type="text" class="form-control" id="city" name="city" value="<?php echo htmlspecialchars($city); ?>" required>
|
||||
</div>
|
||||
<div class="d-grid">
|
||||
<button type="submit" class="btn btn-primary">Sign Up</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<footer class="footer text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
function getCity() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(position => {
|
||||
const lat = position.coords.latitude;
|
||||
const lon = position.coords.longitude;
|
||||
// Using a free reverse geocoding API
|
||||
fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lon}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.address && data.address.city) {
|
||||
document.getElementById('city').value = data.address.city;
|
||||
}
|
||||
})
|
||||
.catch(err => console.error("Error fetching city:", err));
|
||||
});
|
||||
}
|
||||
}
|
||||
window.onload = getCity;
|
||||
</script>
|
||||
<script src="assets/js/city-finder.js?v=<?php echo time(); ?>"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user