v2
This commit is contained in:
parent
2a74e9787f
commit
f3fecfd7d2
@ -1,77 +0,0 @@
|
||||
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
$stmt = $pdo->query('SELECT * FROM communities ORDER BY name');
|
||||
$communities = $stmt->fetchAll();
|
||||
|
||||
?>
|
||||
<!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.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">
|
||||
<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 active" aria-current="page" href="communities.php">Communities</a></li>
|
||||
<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="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<h1 class="text-center mb-4">Welcome to the Communities Page</h1>
|
||||
<div class="row">
|
||||
<?php foreach ($communities as $community): ?>
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="card card-neon h-100">
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h5 class="card-title"><?php echo htmlspecialchars($community['name']); ?></h5>
|
||||
<p class="card-text">Explore and engage with your local community.</p>
|
||||
<div class="mt-auto">
|
||||
<a href="discussions.php?community_id=<?php echo $community['id']; ?>" class="btn btn-primary btn-sm">Discussions</a>
|
||||
<a href="proposals.php?community_id=<?php echo $community['id']; ?>" class="btn btn-secondary btn-sm">Proposals</a>
|
||||
<a href="events.php?community_id=<?php echo $community['id']; ?>" class="btn btn-info btn-sm">Events</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
</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.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
0
conversation.php
Normal file
0
conversation.php
Normal file
@ -8,6 +8,15 @@ if (!isset($_SESSION['user_id'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
if (!isset($_GET['id'])) {
|
||||
header('Location: communities.php');
|
||||
exit;
|
||||
@ -82,6 +91,9 @@ $replies = $stmt->fetchAll();
|
||||
<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>
|
||||
|
||||
@ -8,6 +8,15 @@ if (!isset($_SESSION['user_id'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
if (!isset($_GET['community_id'])) {
|
||||
header('Location: communities.php');
|
||||
exit;
|
||||
@ -112,6 +121,9 @@ $discussions = $stmt->fetchAll();
|
||||
<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>
|
||||
|
||||
@ -8,6 +8,15 @@ if (!isset($_SESSION['user_id'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
if (!isset($_GET['id'])) {
|
||||
header('Location: communities.php');
|
||||
exit;
|
||||
@ -87,7 +96,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<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>
|
||||
<li class="nav-item"><a class="nav-link" href="discussions.php?community_id=<?php echo $discussion['community_id']; ">Discussions</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>
|
||||
|
||||
@ -8,6 +8,15 @@ if (!isset($_SESSION['user_id'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
if (!isset($_GET['id'])) {
|
||||
header('Location: communities.php');
|
||||
exit;
|
||||
@ -83,6 +92,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<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>
|
||||
<li class="nav-item"><a class="nav-link" href="discussions.php?community_id=<?php echo $discussion['community_id']; ">Discussions</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>
|
||||
|
||||
12
event.php
12
event.php
@ -8,6 +8,15 @@ if (!isset($_SESSION['user_id'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
if (!isset($_GET['id'])) {
|
||||
header('Location: communities.php');
|
||||
exit;
|
||||
@ -88,6 +97,9 @@ $user_rsvp = $stmt->fetchColumn();
|
||||
<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>
|
||||
|
||||
12
events.php
12
events.php
@ -8,6 +8,15 @@ if (!isset($_SESSION['user_id'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
if (!isset($_GET['community_id'])) {
|
||||
header('Location: communities.php');
|
||||
exit;
|
||||
@ -93,6 +102,9 @@ $events = $stmt->fetchAll();
|
||||
<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>
|
||||
|
||||
17
index.php
17
index.php
@ -1,5 +1,17 @@
|
||||
|
||||
<?php session_start(); ?>
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php'; // Add this line
|
||||
|
||||
// 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();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@ -23,6 +35,9 @@
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="index.php">Home</a></li>
|
||||
<?php if (isset($_SESSION['user_id'])): ?>
|
||||
<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>
|
||||
|
||||
156
manage_communities.php
Normal file
156
manage_communities.php
Normal file
@ -0,0 +1,156 @@
|
||||
<?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();
|
||||
|
||||
// Check if user is a leader
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$user_id]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
if ($user_role !== 'leader') {
|
||||
// Redirect non-leaders
|
||||
header('Location: communities.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Handle delete
|
||||
if (isset($_GET['delete'])) {
|
||||
$community_id_to_delete = $_GET['delete'];
|
||||
// further check if the current user is the owner of the community
|
||||
$stmt = $pdo->prepare('DELETE FROM communities WHERE id = ? AND leader_id = ?');
|
||||
$stmt->execute([$community_id_to_delete, $user_id]);
|
||||
header('Location: manage_communities.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Handle form submission for creating/editing
|
||||
$name = $description = '';
|
||||
$errors = [];
|
||||
$edit_id = null;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
$edit_id = $_POST['edit_id'] ?? null;
|
||||
|
||||
if (empty($name)) {
|
||||
$errors[] = 'Community name is required';
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
if ($edit_id) {
|
||||
// Update existing community
|
||||
$stmt = $pdo->prepare('UPDATE communities SET name = ?, description = ? WHERE id = ? AND leader_id = ?');
|
||||
$stmt->execute([$name, $description, $edit_id, $user_id]);
|
||||
} else {
|
||||
// Create new community
|
||||
$stmt = $pdo->prepare('INSERT INTO communities (name, description, leader_id) VALUES (?, ?, ?)');
|
||||
$stmt->execute([$name, $description, $user_id]);
|
||||
}
|
||||
header('Location: manage_communities.php');
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
$errors[] = 'Database error: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch community to edit if an id is passed
|
||||
if (isset($_GET['edit'])) {
|
||||
$edit_id = $_GET['edit'];
|
||||
$stmt = $pdo->prepare('SELECT * FROM communities WHERE id = ? AND leader_id = ?');
|
||||
$stmt->execute([$edit_id, $user_id]);
|
||||
$community_to_edit = $stmt->fetch();
|
||||
if ($community_to_edit) {
|
||||
$name = $community_to_edit['name'];
|
||||
$description = $community_to_edit['description'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Fetch all communities led by the user
|
||||
$stmt = $pdo->prepare('SELECT * FROM communities WHERE leader_id = ? ORDER BY created_at DESC');
|
||||
$stmt->execute([$user_id]);
|
||||
$communities = $stmt->fetchAll();
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Manage Communities - Community Hub</title>
|
||||
<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">
|
||||
|
||||
<?php include 'includes/header.php'; ?>
|
||||
|
||||
<main class="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<h1 class="text-center mb-4">Manage Communities</h1>
|
||||
|
||||
<div class="card card-neon mb-4">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title"><?php echo $edit_id ? 'Edit Community' : 'Create a New Community'; ?></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="manage_communities.php" method="POST">
|
||||
<input type="hidden" name="edit_id" value="<?php echo $edit_id; ?>">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Community 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="description" class="form-label">Description</label>
|
||||
<textarea class="form-control" id="description" name="description" rows="3" required><?php echo htmlspecialchars($description); ?></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-gradient"><?php echo $edit_id ? 'Save Changes' : 'Create Community'; ?></button>
|
||||
<?php if ($edit_id): ?>
|
||||
<a href="manage_communities.php" class="btn btn-secondary">Cancel Edit</a>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="mb-3">Your Communities</h2>
|
||||
<div class="list-group">
|
||||
<?php if (empty($communities)): ?>
|
||||
<p>You have not created any communities yet.</p>
|
||||
<?php else: ?>
|
||||
<?php foreach ($communities as $community):
|
||||
<div class="list-group-item">
|
||||
<h5><?php echo htmlspecialchars($community['name']); ?></h5>
|
||||
<p><?php echo htmlspecialchars($community['description']); ?></p>
|
||||
<div>
|
||||
<a href="manage_communities.php?edit=<?php echo $community['id']; ?>" class="btn btn-sm btn-outline-primary">Edit</a>
|
||||
<a href="manage_communities.php?delete=<?php echo $community['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Are you sure you want to delete this community?');">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
0
messages.php
Normal file
0
messages.php
Normal file
170
profile.php
170
profile.php
@ -1,170 +0,0 @@
|
||||
|
||||
<?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 details
|
||||
$stmt = $pdo->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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Your Profile - Community Hub</title>
|
||||
<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">
|
||||
<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>
|
||||
<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">
|
||||
<section class="container mt-5">
|
||||
<h1 class="text-center mb-4">Your Profile</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="card card-neon">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Your Information</h2>
|
||||
<p><strong>Name:</strong> <?php echo htmlspecialchars($user['name']); ?></p>
|
||||
<p><strong>Email:</strong> <?php echo htmlspecialchars($user['email']); ?></p>
|
||||
<p><strong>City:</strong> <?php echo htmlspecialchars($user['city']); ?></p>
|
||||
<p><strong>Role:</strong> <?php echo htmlspecialchars($user['role']); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card card-neon mt-4">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Edit Profile</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="profile.php" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">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="city" class="form-label">City</label>
|
||||
<input type="text" class="form-control" id="city" name="city" value="<?php echo htmlspecialchars($city); ?>" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-gradient">Save Changes</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="card card-neon">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Your Communities</h2>
|
||||
<div class="list-group">
|
||||
<?php if (empty($communities)): ?>
|
||||
<p>You are not a member of any communities yet.</p>
|
||||
<?php else: ?>
|
||||
<?php foreach ($communities as $community): ?>
|
||||
<a href="discussions.php?community_id=<?php echo $community['id']; ?>" class="list-group-item list-group-item-action">
|
||||
<?php echo htmlspecialchars($community['name']); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card card-neon mt-4">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Your Discussions</h2>
|
||||
<div class="list-group">
|
||||
<?php if (empty($discussions)): ?>
|
||||
<p>You have not started any discussions yet.</p>
|
||||
<?php else: ?>
|
||||
<?php foreach ($discussions as $discussion): ?>
|
||||
<a href="discussion.php?id=<?php echo $discussion['id']; ?>" class="list-group-item list-group-item-action">
|
||||
<?php echo htmlspecialchars($discussion['title']); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</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.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
152
proposal.php
152
proposal.php
@ -1,152 +0,0 @@
|
||||
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($_GET['id'])) {
|
||||
header('Location: communities.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$proposal_id = $_GET['id'];
|
||||
$user_id = $_SESSION['user_id'];
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch proposal details
|
||||
$stmt = $pdo->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();
|
||||
|
||||
?>
|
||||
<!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($proposal['title']); ?> - Community Hub</title>
|
||||
<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">
|
||||
<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>
|
||||
<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="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<div class="card card-neon mb-4">
|
||||
<div class="card-header">
|
||||
<h1 class="mb-0"><?php echo htmlspecialchars($proposal['title']); ?></h1>
|
||||
<small>in <a href="discussions.php?community_id=<?php echo $proposal['community_id']; ?>"><?php echo htmlspecialchars($proposal['community_name']); ?></a> by <?php echo htmlspecialchars($proposal['user_name']); ?> on <?php echo date('M j, Y, g:i a', strtotime($proposal['created_at'])); ?></small>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p><?php echo nl2br(htmlspecialchars($proposal['description'])); ?></p>
|
||||
<p><strong>Voting ends:</strong> <?php echo date('M j, Y, g:i a', strtotime($proposal['end_time'])); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Voting</h2>
|
||||
<div class="d-flex justify-content-around mb-4">
|
||||
<div class="text-center">
|
||||
<h3>Upvotes</h3>
|
||||
<p class="display-4"><?php echo $up_votes; ?></p>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<h3>Downvotes</h3>
|
||||
<p class="display-4"><?php echo $down_votes; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (strtotime($proposal['end_time']) > time()): ?>
|
||||
<div class="card card-neon">
|
||||
<div class="card-body text-center">
|
||||
<h2 class="card-title">Cast Your Vote</h2>
|
||||
<form action="proposal.php?id=<?php echo $proposal_id; ?>" method="POST" class="d-inline">
|
||||
<input type="hidden" name="vote" value="up">
|
||||
<button type="submit" class="btn btn-success btn-lg me-2 <?php echo ($user_vote === 'up') ? 'active' : ''; ?>">Vote Up</button>
|
||||
</form>
|
||||
<form action="proposal.php?id=<?php echo $proposal_id; ?>" method="POST" class="d-inline">
|
||||
<input type="hidden" name="vote" value="down">
|
||||
<button type="submit" class="btn btn-danger btn-lg <?php echo ($user_vote === 'down') ? 'active' : ''; ?>">Vote Down</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="alert alert-info text-center">Voting on this proposal has ended.</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</section>
|
||||
</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.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
161
proposals.php
161
proposals.php
@ -1,161 +0,0 @@
|
||||
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($_GET['community_id'])) {
|
||||
header('Location: communities.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$community_id = $_GET['community_id'];
|
||||
$user_id = $_SESSION['user_id'];
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch community details
|
||||
$stmt = $pdo->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();
|
||||
|
||||
?>
|
||||
<!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($community['name']); ?> Proposals - Community Hub</title>
|
||||
<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">
|
||||
<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>
|
||||
<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="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<h1 class="text-center mb-4">Proposals in <?php echo htmlspecialchars($community['name']); ?></h1>
|
||||
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<div class="card card-neon mb-4">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Create a New Proposal</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="proposals.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="description" class="form-label">Description</label>
|
||||
<textarea class="form-control" id="description" name="description" rows="3" required><?php echo htmlspecialchars($description); ?></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="end_time" class="form-label">End Time</label>
|
||||
<input type="datetime-local" class="form-control" id="end_time" name="end_time" value="<?php echo htmlspecialchars($end_time); ?>" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-gradient">Create Proposal</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<h2>Active Proposals</h2>
|
||||
<div class="list-group">
|
||||
<?php if (empty($proposals)): ?>
|
||||
<p>No proposals yet. <?php if ($user_role === 'leader'): ?>Be the first to create one!<?php endif; ?></p>
|
||||
<?php else: ?>
|
||||
<?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>Ends <?php echo date('M j, Y, g:i a', strtotime($proposal['end_time'])); ?></small>
|
||||
</div>
|
||||
<p class="mb-1">Created by: <?php echo htmlspecialchars($proposal['user_name']); ?></p>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
</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.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
69
temp_update.sh
Normal file
69
temp_update.sh
Normal file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
FILES=("discussions.php" "discussion.php" "edit_discussion.php" "edit_reply.php" "event.php" "events.php" "profile.php" "proposal.php" "proposals.php" "messages.php" "conversation.php")
|
||||
|
||||
PHP_SNIPPET_TO_REPLACE="if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}"
|
||||
|
||||
PHP_SNIPPET_REPLACEMENT="if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}"
|
||||
|
||||
HTML_SNIPPET_TO_REPLACE='<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>'
|
||||
|
||||
HTML_SNIPPET_REPLACEMENT='<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>'
|
||||
|
||||
for FILE in "${FILES[@]}"
|
||||
do
|
||||
# Use a temporary file to avoid issues with sed -i
|
||||
sed "s|$PHP_SNIPPET_TO_REPLACE|$PHP_SNIPPET_REPLACEMENT|" "$FILE" > "${FILE}.tmp"
|
||||
mv "${FILE}.tmp" "$FILE"
|
||||
|
||||
sed "s|$HTML_SNIPPET_TO_REPLACE|$HTML_SNIPPET_REPLACEMENT|" "$FILE" > "${FILE}.tmp"
|
||||
mv "${FILE}.tmp" "$FILE"
|
||||
done
|
||||
|
||||
# Special cases with active class
|
||||
|
||||
HTML_SNIPPET_TO_REPLACE_ACTIVE_COMMUNITIES='<li class="nav-item"><a class="nav-link active" aria-current="page" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>'
|
||||
|
||||
HTML_SNIPPET_REPLACEMENT_ACTIVE_COMMUNITIES='<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>'
|
||||
|
||||
sed "s|$HTML_SNIPPET_TO_REPLACE_ACTIVE_COMMUNITIES|$HTML_SNIPPET_REPLACEMENT_ACTIVE_COMMUNITIES|" "communities.php" > "communities.php.tmp"
|
||||
mv "communities.php.tmp" "communities.php"
|
||||
|
||||
|
||||
HTML_SNIPPET_TO_REPLACE_ACTIVE_PROFILE='<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="profile.php">Profile</a></li>'
|
||||
|
||||
HTML_SNIPPET_REPLACEMENT_ACTIVE_PROFILE='<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>'
|
||||
|
||||
sed "s|$HTML_SNIPPET_TO_REPLACE_ACTIVE_PROFILE|$HTML_SNIPPET_REPLACEMENT_ACTIVE_PROFILE|" "profile.php" > "profile.php.tmp"
|
||||
mv "profile.php.tmp" "profile.php"
|
||||
Loading…
x
Reference in New Issue
Block a user