���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home/alphpwcp/previewstream.online/gfherhfghre/commentsos/vendoyters/admin.tar
���ѧ٧ѧ�
edit_company.php 0000644 00000007575 15177072416 0007760 0 ustar 00 <?php session_start(); if (!isset($_SESSION['admin_id'])) { header('Location: login.php'); exit; } include '../db.php'; // Pagination config $limit = 10; $page = isset($_GET['page']) && is_numeric($_GET['page']) ? (int)$_GET['page'] : 1; $offset = ($page - 1) * $limit; // Count total companies $total_stmt = $pdo->query("SELECT COUNT(*) FROM companies"); $total_companies = $total_stmt->fetchColumn(); $total_pages = ceil($total_companies / $limit); // Fetch companies for current page $stmt = $pdo->prepare(" SELECT c.*, cat.name AS category_name FROM companies c LEFT JOIN categories cat ON c.category_id = cat.id ORDER BY c.id DESC LIMIT :limit OFFSET :offset "); $stmt->bindValue(':limit', $limit, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); $stmt->execute(); $companies = $stmt->fetchAll(); ?> <?php include 'menu.php'; ?> <!DOCTYPE html> <html> <head> <title>Edit Companies</title> <link rel="stylesheet" href="../style.css"> <style> .container { max-width: 1000px; margin: 2rem auto; } table { border-collapse: collapse; width: 100%; margin-top: 1rem; } th, td { border: 1px solid #ddd; padding: 8px; text-align: left; vertical-align: top; } th { background-color: #f2f2f2; } tr:nth-child(even){background-color: #fafafa;} tr:hover {background-color: #f1f1f1;} img { border-radius: 4px; } .pagination a { margin: 0 5px; text-decoration: none; padding: 5px 10px; border: 1px solid #ccc; border-radius: 4px; } .pagination a.active { background: #007BFF; color: white; border-color: #007BFF; } h2 { margin-bottom: 1rem; } </style> </head> <body> <div class="container"> <h2>Edit / Update Companies</h2> <table> <tr> <th>ID</th> <th>Name</th> <th>Website</th> <th>Region</th> <th>Category</th> <th>Image</th> <th>Description</th> <th>Action</th> </tr> <?php foreach($companies as $c): ?> <tr> <td><?php echo $c['id']; ?></td> <td><?php echo htmlspecialchars($c['name']); ?></td> <td><?php echo htmlspecialchars($c['website']); ?></td> <td><?php echo htmlspecialchars($c['region']); ?></td> <td><?php echo htmlspecialchars($c['category_name']); ?></td> <td> <?php if($c['image']): ?> <img src="../images/companies/<?php echo htmlspecialchars($c['image']); ?>" width="50"> <?php else: ?> N/A <?php endif; ?> </td> <td><?php echo htmlspecialchars(mb_strimwidth($c['description'], 0, 50, '...')); ?></td> <td> <a href="edit_single.php?id=<?php echo $c['id']; ?>">Edit</a> / <a href="delete_company.php?id=<?php echo $c['id']; ?>" onclick="return confirm('Are you sure?');">Delete</a> </td> </tr> <?php endforeach; ?> </table> <!-- Pagination links --> <div class="pagination" style="margin-top:15px;"> <?php if($total_pages > 1): ?> <?php for($i = 1; $i <= $total_pages; $i++): ?> <a href="?page=<?php echo $i; ?>" class="<?php echo ($i == $page ? 'active' : ''); ?>"><?php echo $i; ?></a> <?php endfor; ?> <?php endif; ?> </div> <p><a href="dashboard.php">← Back to Dashboard</a></p> </div> </body> </html> add_admin.php 0000644 00000002215 15177072416 0007167 0 ustar 00 <?php session_start(); if (!isset($_SESSION['admin_id'])) { header('Location: login.php'); exit; } include '../db.php'; $error = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $username = trim($_POST['username']); $password = trim($_POST['password']); $hash = password_hash($password, PASSWORD_DEFAULT); try { $stmt = $pdo->prepare("INSERT INTO admins (username, password) VALUES (?, ?)"); $stmt->execute([$username, $hash]); header('Location: manage_admins.php'); exit; } catch (Exception $e) { $error = "Error: username might already exist."; } } ?> <?php include 'menu.php'; ?> <!DOCTYPE html> <html> <head> <title>Add Admin</title><link rel="stylesheet" href="../style.css"> </head> <body> <h2>Add New Admin</h2> <?php if($error): ?><p style="color:red;"><?= htmlspecialchars($error) ?></p><?php endif; ?> <form method="POST"> <input type="text" name="username" placeholder="Username" required><br><br> <input type="password" name="password" placeholder="Password" required><br><br> <button type="submit">Add Admin</button> </form> </body></html> termsofuse.php 0000644 00000022374 15177072416 0007473 0 ustar 00 <?php header('Content-Type: text/html; charset=utf-8'); session_start(); include 'db.php'; // Latest reviews $latestReviews = $pdo->query(" SELECT r.comment, r.rating, u.username, c.name AS company_name FROM reviews r JOIN users u ON r.user_id = u.id JOIN companies c ON r.company_id = c.id ORDER BY r.id DESC LIMIT 5 ")->fetchAll(); // Top companies $topCompanies = $pdo->query(" SELECT c.id, c.name, c.image, ROUND(AVG(r.rating),1) AS avg_rating FROM companies c JOIN reviews r ON c.id = r.company_id GROUP BY c.id HAVING COUNT(r.id) >= 1 ORDER BY avg_rating DESC LIMIT 5 ")->fetchAll(); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Terms of Use - Review Stream</title> <link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <!-- Sans-serif fonts --> <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Raleway&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Roboto+Slab&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Noto+Serif&display=swap" rel="stylesheet"> <!-- Favicon --> <link rel="icon" href="/favicon.png" type="image/png" /> <style> body { font-family: Arial, sans-serif; font-size: 16px; line-height: 1.7; padding-bottom: 60px} .content-layout { display: flex; gap: 20px; flex-wrap: wrap; } .main-content { flex: 3; min-width: 250px; } .sidebar { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 15px; } .legal-section { background: #f9f9f9; padding: 22px; border-radius: 8px; margin-bottom: 20px; } .legal-section h3 { color: #4A90E2; margin-top: 0; font-size: 20px; } .highlight-box { background: #e6f4ea; padding: 14px; border-left: 4px solid #28a745; margin: 15px 0; border-radius: 4px; } .star-box { display: inline-block; width: 16px; height: 16px; font-size: 12px; line-height: 16px; text-align: center; border-radius: 3px; margin-right: 2px; color: white; background-color: #ccc; } .star-box.filled { background-color: #28a745; } .fixed-footer { position: fixed; left: 0; bottom: 0; width: 100%; background: #222; text-align: center; padding: 10px 0; color: #fff; z-index: 1000; } .fixed-footer p{ font-family: 'Poppins', sans-serif !important; font-size: 13px !important; } .footer-menu a { margin: 0 10px; text-decoration: none; color: #fff; font-family: 'Poppins', sans-serif !important; font-size: 13px !important; } .footer-menu a:hover { text-decoration: underline; } /* Collapsible menu */ .menu { display: none; flex-direction: column; } .menu.active { display: flex; } .menu a { padding: 8px 0; text-decoration: none; color: #333; } .menu-toggle { font-size: 1.5em; cursor: pointer; } @media(min-width: 768px){ .menu { display: flex !important; flex-direction: row; } .menu a { margin-left: 15px; } .menu-toggle { display: none; } } .topbar { display:flex; justify-content:space-between; align-items:center; padding:10px 20px; background:#007BFF; color:white; } .logo { font-size: 20px; font-weight: bold; display: flex; align-items: center; gap: 10px; } .logo-icon { display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #a2d4f5, #fefb72); /* light blue to lemon */ border-radius: 50%; width: 36px; height: 36px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); margin-right: 8px; } </style> </head> <body> <div class="topbar"> <div class="logo"><div class="logo-icon"><i class="fas fa-shield-alt" style="color: skyblue; font-size: 25px; margin-left: 6px !important; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);"></i> </div> REVIEW STREAM </div> <div class="menu-toggle" onclick="document.querySelector('.menu').classList.toggle('active')"> <i class="fas fa-bars"></i> </div> <div class="menu"> <a href="index.php">Home</a> <a href="companies.php">Companies</a> <a href="blog.php">Newsroom</a> <?php if(isset($_SESSION['user_id'])): ?> <a href="logout.php">Logout</a> <?php else: ?> <a href="login.php">Login</a> <?php endif; ?> <button class="dark-mode-toggle" onclick="document.body.classList.toggle('dark-mode')">🌓</button> </div> </div> <div class="container"> <div class="content-layout"> <div class="main-content"> <div class="card"> <h2>Terms of Use</h2> <p>Welcome to Review Stream! These Terms of Use explain your rights and responsibilities when using our platform. By accessing our website, you agree to follow these terms.</p> <div class="legal-section"> <h3><i class="fas fa-user-shield"></i> User Conduct</h3> <p>We ask that all users act respectfully and responsibly. You agree not to post content that is unlawful, defamatory, harassing, abusive, hateful, threatening, or violates the rights of others.</p> <p>Spam, advertising, repetitive posts, or attempts to manipulate ratings are prohibited. We reserve the right to remove content and suspend accounts that breach these guidelines.</p> <p>By using Review Stream, you commit to contributing genuine reviews based on your actual experiences.</p> </div> <div class="legal-section"> <h3><i class="fas fa-file-contract"></i> Content Ownership</h3> <p>Everything you post (reviews, comments, images) remains your intellectual property. However, you grant Review Stream a worldwide, non-exclusive, royalty-free license to store, display, reproduce, and share your content on our platform, social media, and marketing materials.</p> <p>We do not claim ownership of your content, but we need this license so that your reviews can appear publicly to help other users.</p> </div> <div class="legal-section"> <h3><i class="fas fa-shield-alt"></i> Disclaimer & Liability</h3> <p>All content on Review Stream is provided “as is.” We do not guarantee the accuracy, completeness, or reliability of user-generated reviews or third-party information.</p> <p>We are not responsible for losses or damages arising from reliance on content posted by users. Users should always cross-check and make independent decisions.</p> <div class="highlight-box"> <strong>Important:</strong> Reviews reflect personal opinions. Businesses should not be judged solely on single reviews; consider trends over time. </div> </div> <div class="legal-section"> <h3><i class="fas fa-sync-alt"></i> Changes to Terms</h3> <p>We may update these Terms of Use to reflect changes to our service, legal requirements, or user feedback. We will post the updated version on this page with a new effective date.</p> <p>Continuing to use our website after changes become effective means you accept the revised terms.</p> </div> <div class="legal-section"> <h3><i class="fas fa-envelope"></i> Contact Us</h3> <p>If you have any questions about these Terms, please reach out to our support team at <a href="mailto:support@reviewstream.com">info@previewstream.online</a>. We value open dialogue and user feedback.</p> </div> <p style="font-size: 14px; color: #666;">Effective date: January 1, 2025</p> </div> </div> <div class="sidebar"> <div class="sidebar-card"> <h4>Latest Reviews</h4> <?php foreach($latestReviews as $rev): ?> <p><strong><?= htmlspecialchars($rev['username']) ?></strong> on <em><?= htmlspecialchars($rev['company_name']) ?></em>:</p> <div> <?php for($i=1;$i<=5;$i++): ?> <span class="star-box <?= $i<=$rev['rating'] ? 'filled' : '' ?>">★</span> <?php endfor; ?> (<?= $rev['rating'] ?>/5) </div> <p style="margin-top:2px;"><?= htmlspecialchars(substr($rev['comment'],0,50)) ?>...</p> <hr> <?php endforeach; ?> </div> <div class="sidebar-card"> <h4>Top Rated Companies</h4> <?php foreach($topCompanies as $top): ?> <div style="display:flex;align-items:center;gap:8px;margin-bottom:5px;"> <img src="images/companies/<?= htmlspecialchars($top['image']) ?>" alt="<?= htmlspecialchars($top['name']) ?>" style="width:30px;height:30px;object-fit:contain;"> <span><?= htmlspecialchars($top['name']) ?> (<?= $top['avg_rating'] ?>/5)</span> </div> <?php endforeach; ?> </div> </div> </div> </div> <?php include 'footer.php'; ?> </body> </html> edit_blog.php 0000644 00000004416 15177072416 0007224 0 ustar 00 <?php session_start(); require_once '../db.php'; // include your db connection via PDO $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; // Fetch blog post $stmt = $pdo->prepare("SELECT * FROM blogs WHERE id = ?"); $stmt->execute([$id]); $blog = $stmt->fetch(PDO::FETCH_ASSOC); if (!$blog) { die("Blog post not found."); } if ($_SERVER["REQUEST_METHOD"] === "POST") { $title = $_POST['title']; $slug = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $title))); $content = $_POST['content']; $category_id = $_POST['category_id']; $image = $blog['image']; if (!empty($_FILES['image']['name'])) { $target = "../uploads/" . basename($_FILES['image']['name']); if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) { $image = $_FILES['image']['name']; } } $stmt = $pdo->prepare("UPDATE blogs SET title = ?, slug = ?, content = ?, image = ?, category_id = ? WHERE id = ?"); $stmt->execute([$title, $slug, $content, $image, $category_id, $id]); header("Location: blog_list.php"); exit; } // Fetch categories $catStmt = $pdo->query("SELECT * FROM categories"); $categories = $catStmt->fetchAll(PDO::FETCH_ASSOC); ?> <?php include 'menu.php'; ?> <!DOCTYPE html> <html> <head><title>Edit Blog Post</title></head> <body> <h1>Edit Blog Post</h1> <form method="post" enctype="multipart/form-data"> <input type="text" name="title" value="<?= htmlspecialchars($blog['title']) ?>" required><br><br> <textarea name="content" rows="5" required><?= htmlspecialchars($blog['content']) ?></textarea><br><br> <select name="category_id" required> <option value="">-- Select Category --</option> <?php foreach ($categories as $cat): ?> <option value="<?= $cat['id'] ?>" <?= $cat['id'] == $blog['category_id'] ? 'selected' : '' ?>> <?= htmlspecialchars($cat['name']) ?> </option> <?php endforeach; ?> </select><br><br> <?php if (!empty($blog['image'])): ?> <img src="../uploads/<?= htmlspecialchars($blog['image']) ?>" width="100"><br> <?php endif; ?> <input type="file" name="image"><br><br> <button type="submit">Update Blog</button> </form> </body> </html> logout.php 0000644 00000000130 15177072416 0006572 0 ustar 00 <?php session_start(); session_destroy(); header('Location: login.php'); exit; ?> edit_category.php 0000644 00000003602 15177072416 0010112 0 ustar 00 <?php session_start(); if (!isset($_SESSION['admin_id'])) { header('Location: login.php'); exit; } include '../db.php'; // Handle update if (isset($_POST['edit_id'], $_POST['new_name'])) { $stmt = $pdo->prepare("UPDATE categories SET name = ? WHERE id = ?"); $stmt->execute([trim($_POST['new_name']), $_POST['edit_id']]); } // Handle delete if (isset($_GET['delete_id'])) { $stmt = $pdo->prepare("DELETE FROM categories WHERE id = ?"); $stmt->execute([$_GET['delete_id']]); header('Location: edit_categories.php'); exit; } // Fetch all categories $categories = $pdo->query("SELECT * FROM categories ORDER BY id DESC")->fetchAll(); ?> <?php include 'menu.php'; ?> <!DOCTYPE html> <html> <head> <title>Edit Categories</title> <link rel="stylesheet" href="../style.css"> <style> form.inline { display:inline; } input[type="text"] { padding:2px; } </style> </head> <body> <div class="container"> <h2>Edit / Delete Categories</h2> <table border="1" cellpadding="5"> <tr> <th>ID</th><th>Name</th><th>Action</th> </tr> <?php foreach($categories as $cat): ?> <tr> <td><?= $cat['id'] ?></td> <td> <form method="POST" class="inline"> <input type="hidden" name="edit_id" value="<?= $cat['id'] ?>"> <input type="text" name="new_name" value="<?= htmlspecialchars($cat['name']) ?>" required> <button type="submit">Update</button> </form> </td> <td> <a href="?delete_id=<?= $cat['id'] ?>" onclick="return confirm('Are you sure?');">Delete</a> </td> </tr> <?php endforeach; ?> </table> <p><a href="dashboard.php">Back to Dashboard</a></p> </div> </body> </html> delete_review.php 0000644 00000000736 15177072416 0010120 0 ustar 00 <?php session_start(); if (!isset($_SESSION['admin_id'])) { header('Location: login.php'); exit; } include '../db.php'; // Validate and sanitize ID $id = isset($_GET['id']) ? intval($_GET['id']) : 0; if ($id > 0) { $stmt = $pdo->prepare("DELETE FROM reviews WHERE id = ?"); $stmt->execute([$id]); } // Redirect back to manage_review.php (note: your old file was called manage_reviews.php) header('Location: manage_review.php'); exit; ?> add_company.php 0000644 00000005450 15177072416 0007551 0 ustar 00 <?php session_start(); if (!isset($_SESSION['admin_id'])) { header('Location: login.php'); exit; } include '../db.php'; // Fetch categories for dropdown $categories = $pdo->query("SELECT id, name FROM categories")->fetchAll(); $success = ''; $error = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name = trim($_POST['name']); $website = trim($_POST['website']); $region = trim($_POST['region']); $category_id = intval($_POST['category_id']); $description = trim($_POST['description']); $imageName = ''; if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) { $imageName = basename($_FILES['image']['name']); move_uploaded_file($_FILES['image']['tmp_name'], "../images/companies/" . $imageName); } $stmt = $pdo->prepare("INSERT INTO companies (name, website, region, image, category_id, description) VALUES (?,?,?,?,?,?)"); $ok = $stmt->execute([$name, $website, $region, $imageName, $category_id, $description]); if ($ok) { $success = "Company added successfully!"; } else { $error = "Failed to add company."; } } ?> <?php include 'menu.php'; ?> <!DOCTYPE html> <html> <head> <title>Add Company</title> <link rel="stylesheet" href="../style.css"> <style> .container { max-width:400px; margin:2rem auto; } form { display:flex; flex-direction:column; gap:0.8rem; } input[type="text"], textarea, input[type="password"], select { padding:0.6rem; border-radius:6px; border:1px solid #ccc; } button { padding:0.6rem; background:#007BFF; color:#fff; border:none; border-radius:6px; cursor:pointer; } button:hover { background:#0056b3; } </style> </head> <body> <div class="container"> <h2>Add New Company</h2> <?php if($success): ?><p style="color:green;"><?= htmlspecialchars($success) ?></p><?php endif; ?> <?php if($error): ?><p style="color:red;"><?= htmlspecialchars($error) ?></p><?php endif; ?> <form method="POST" enctype="multipart/form-data"> <input type="text" name="name" placeholder="Company Name" required> <input type="text" name="website" placeholder="Website"> <input type="text" name="region" placeholder="Region"> <select name="category_id" required> <option value="">Select Category</option> <?php foreach($categories as $cat): ?> <option value="<?= $cat['id'] ?>"><?= htmlspecialchars($cat['name']) ?></option> <?php endforeach; ?> </select> <textarea name="description" placeholder="Company Description" rows="5"></textarea> <input type="file" name="image" accept="image/*"> <button type="submit">Add Company</button> </form> <p><a href="dashboard.php">Back to Dashboard</a></p> </div> </body> </html> manage_review.php 0000644 00000006062 15177072416 0010104 0 ustar 00 <?php session_start(); if (!isset($_SESSION['admin_id'])) { header('Location: login.php'); exit; } include '../db.php'; // Pagination config $limit = 10; // reviews per page $page = isset($_GET['page']) && is_numeric($_GET['page']) ? (int)$_GET['page'] : 1; $offset = ($page - 1) * $limit; // Count total reviews $total_stmt = $pdo->query("SELECT COUNT(*) FROM reviews"); $total_reviews = $total_stmt->fetchColumn(); $total_pages = ceil($total_reviews / $limit); // Fetch reviews for current page with related user and company info $stmt = $pdo->prepare(" SELECT r.id, r.comment, r.rating, u.username, c.name AS company_name FROM reviews r JOIN users u ON r.user_id = u.id JOIN companies c ON r.company_id = c.id ORDER BY r.id DESC LIMIT :limit OFFSET :offset "); $stmt->bindValue(':limit', $limit, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); $stmt->execute(); $reviews = $stmt->fetchAll(); ?> <?php include 'menu.php'; ?> <!DOCTYPE html> <html> <head> <title>Manage Reviews</title> <link rel="stylesheet" href="../style.css"> <style> table { border-collapse: collapse; width: 100%; } th, td { padding: 8px; border: 1px solid #ccc; text-align: left; } th { background-color: #f2f2f2; } .delete-link { color: red; text-decoration: none; } .pagination a { margin: 0 5px; text-decoration: none; padding: 5px 10px; border: 1px solid #ccc; border-radius: 4px; } .pagination a.active { background: #007BFF; color: white; border-color: #007BFF; } </style> </head> <body> <div class="container"> <h2>All Reviews</h2> <table> <tr> <th>ID</th> <th>User</th> <th>Company</th> <th>Rating</th> <th>Comment</th> <th>Action</th> </tr> <?php foreach($reviews as $r): ?> <tr> <td><?= $r['id'] ?></td> <td><?= htmlspecialchars($r['username']) ?></td> <td><?= htmlspecialchars($r['company_name']) ?></td> <td><?= $r['rating'] ?></td> <td><?= htmlspecialchars(substr($r['comment'], 0, 50)) ?><?= strlen($r['comment']) > 50 ? '...' : '' ?></td> <td> <a href="edit_review.php?id=<?= $r['id'] ?>">✏ Edit</a> / <a href="delete_review.php?id=<?= $r['id'] ?>" onclick="return confirm('Delete review?');">🗑 Delete</a> </td> </tr> <?php endforeach; ?> </table> <!-- Pagination links --> <div class="pagination" style="margin-top:15px;"> <?php if($total_pages > 1): ?> <?php for($i = 1; $i <= $total_pages; $i++): ?> <a href="?page=<?= $i ?>" class="<?= $i == $page ? 'active' : '' ?>"><?= $i ?></a> <?php endfor; ?> <?php endif; ?> </div> <p><a href="dashboard.php">← Back to Dashboard</a></p> </div> </body> </html> user-settings.php 0000644 00000020360 15177072416 0010104 0 ustar 00 <?php header('Content-Type: text/html; charset=utf-8'); session_start(); include 'db.php'; if (!isset($_SESSION['user_id'])) { header('Location: login.php'); exit(); } $userId = $_SESSION['user_id']; $message = ''; // Fetch current user info $stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?"); $stmt->execute([$userId]); $user = $stmt->fetch(); // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST') { $newUsername = $_POST['username']; $newEmail = $_POST['email']; $newPassword = $_POST['password']; $confirmPassword = $_POST['confirm_password']; $uploadDir = 'images/user/'; $profileImage = $user['profile_image']; // Handle new image upload if (isset($_FILES['profile_image']) && $_FILES['profile_image']['error'] === UPLOAD_ERR_OK) { $tmpName = $_FILES['profile_image']['tmp_name']; $originalName = basename($_FILES['profile_image']['name']); $ext = strtolower(pathinfo($originalName, PATHINFO_EXTENSION)); $allowed = ['jpg', 'jpeg', 'png', 'webp']; if (in_array($ext, $allowed)) { $newName = uniqid('profile_', true) . '.' . $ext; move_uploaded_file($tmpName, $uploadDir . $newName); $profileImage = $newName; } else { $message = "<span style='color:red;'>Invalid image format. Use JPG, PNG, or WEBP.</span>"; } } if (!$message) { if (!empty($newPassword)) { if ($newPassword === $confirmPassword) { $hashedPassword = password_hash($newPassword, PASSWORD_DEFAULT); $stmt = $pdo->prepare("UPDATE users SET username=?, email=?, password=?, profile_image=? WHERE id=?"); $stmt->execute([$newUsername, $newEmail, $hashedPassword, $profileImage, $userId]); $message = "<span style='color:green;'>Profile and password updated successfully.</span>"; } else { $message = "<span style='color:red;'>Passwords do not match.</span>"; } } else { $stmt = $pdo->prepare("UPDATE users SET username=?, email=?, profile_image=? WHERE id=?"); $stmt->execute([$newUsername, $newEmail, $profileImage, $userId]); $message = "<span style='color:green;'>Profile updated successfully.</span>"; } } // Reload updated data $stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?"); $stmt->execute([$userId]); $user = $stmt->fetch(); } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>User Settings - Review Stream</title> <link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet"> <!-- Sans-serif fonts --> <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Raleway&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Roboto+Slab&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Noto+Serif&display=swap" rel="stylesheet"> <!-- Favicon --> <link rel="icon" href="/favicon.png" type="image/png" /> <style> body{ margin:0; font-family: 'Roboto', sans-serif; line-height: 1.6; padding-bottom: 260px; } .container { max-width: 500px; margin: 2rem auto; font-family: Arial, sans-serif; } form { display: flex; flex-direction: column; gap: 1rem; } input[type="text"], input[type="email"], input[type="password"], input[type="file"] { padding: 0.6rem; border-radius: 6px; border: 1px solid #ccc; } .update-settings { padding: 0.6rem; background: #007BFF; color: #fff; border: none; border-radius: 6px; cursor: pointer; } .update-settings:hover { background: #1e7e34; } .profile-pic { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 2px solid #ddd; display: block; margin: 0 auto 1rem; } .fixed-footer { position: fixed; left: 0; bottom: 0; width: 100%; background: #222; text-align: center; padding: 10px 0; color: #fff; z-index: 1000; } .fixed-footer p{ font-family: 'Poppins', sans-serif !important; font-size: 13px !important; } .footer-menu a { margin: 0 10px; text-decoration: none; color: #fff; font-family: 'Poppins', sans-serif !important; font-size: 13px !important; } .footer-menu a:hover { text-decoration: underline; } .topbar { background-color: #007BFF; /* Blue */ color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 10px 15px; position: relative; } .logo { display: flex; align-items: center; font-weight: bold; font-size: 18px; } .logo-icon { background: linear-gradient(135deg, #a2d4f5, #fefb72); border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; margin-right: 8px; } .menu-toggle { font-size: 1.5em; color: #fff; cursor: pointer; display: none; } .menu { display: flex; gap: 15px; } .menu a, .menu button { color: #fff; text-decoration: none; background: none; border: none; cursor: pointer; } /* Mobile styles */ @media (max-width: 768px) { .menu-toggle { display: block; } .menu { flex-direction: column; background-color: #007BFF; position: absolute; top: 60px; left: 0; right: 0; display: none; padding: 10px 0; z-index: 1000; } .menu.active { display: flex; } .menu a, .menu button { padding: 10px 15px; } } </style> </head> <body> <div class="topbar"> <div class="logo"> <div class="logo-icon"> <i class="fas fa-shield-alt" style="color:#4A90E2; font-size: 25px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); margin-left: 8px"></i> </div> REVIEW STREAM </div> <div class="menu-toggle" onclick="toggleMenu()"> <i class="fas fa-bars"></i> </div> <div class="menu" id="topMenu"> <a href="index.php">Home</a> <a href="companies.php">Companies</a> <a href="blog.php">Newsroom</a> <?php if(isset($_SESSION['user_id'])): ?> <a href="user-settings.php">My Settings</a> <a href="logout.php">Logout</a> <?php else: ?> <a href="login.php">Login</a> <?php endif; ?> <button class="dark-mode-toggle" onclick="document.body.classList.toggle('dark-mode')">🌓</button> </div> </div> <div class="container"> <h2 style="text-align:center;">Update Your Profile</h2> <?php if ($message): ?> <div style="text-align:center;"><?= $message ?></div> <?php endif; ?> <form method="post" enctype="multipart/form-data"> <img src="images/user/<?= htmlspecialchars($user['profile_image']) ?>" alt="Profile Image" class="profile-pic"> <label>Change profile image:</label> <input type="file" name="profile_image" accept="image/*"> <label>Username:</label> <input type="text" name="username" value="<?= htmlspecialchars($user['username']) ?>" required> <label>Email:</label> <input type="email" name="email" value="<?= htmlspecialchars($user['email']) ?>" required> <label>New Password (leave blank if not changing):</label> <input type="password" name="password"> <label>Confirm New Password:</label> <input type="password" name="confirm_password"> <button class="update-settings" type="submit">Update Profile</button> </form> </div> <?php include 'footer.php'; ?> <script> function toggleMenu() { document.getElementById('topMenu').classList.toggle('active'); } </script> </body> </html> menu.php 0000644 00000002172 15177072416 0006235 0 ustar 00 <!-- admin_nav.php (or copy this block into each admin page) --> <style> .admin-nav { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; background: #333; color: #fff; padding: 10px 20px; } .admin-nav a { color: #fff; text-decoration: none; margin: 5px 10px; } .admin-nav a:hover { text-decoration: underline; } .admin-nav .menu { display: flex; flex-wrap: wrap; } @media (max-width: 600px) { .admin-nav .menu { flex-direction: column; align-items: flex-start; } } .admin-nav .menu a{ font-size: 11px !important; } </style> <div class="admin-nav"> <div class="logo">Admin Panel</div> <div class="menu"> <a href="dashboard.php">Dashboard</a> <a href="add_company.php">Add Company</a> <a href="edit_company.php">Manage Companies</a> <a href="manage_review.php">Manage Reviews</a> <a href="edit_category.php">Edit Category</a> <a href="add_category.php">Add Category</a> <a href="blog_list.php">Manage Blog</a> <a href="add_blog.php">Add Blog</a> <a href="manage_admin.php">Manage Admins</a> <a href="logout.php">Logout</a> </div> </div> blog_list.php 0000644 00000003040 15177072416 0007242 0 ustar 00 <?php session_start(); require_once '../db.php'; // Adjust path if needed include 'menu.php'; // Fetch blog posts with categories $stmt = $pdo->query(" SELECT blogs.*, categories.name AS category FROM blogs LEFT JOIN categories ON blogs.category_id = categories.id ORDER BY blogs.created_at DESC "); $blogs = $stmt->fetchAll(PDO::FETCH_ASSOC); ?> <!DOCTYPE html> <html> <head> <title>Manage Blogs</title> <style> table { border-collapse: collapse; width: 100%; } th, td { border: 1px solid #ccc; padding: 8px; font-family: Arial, sans-serif; } th { background-color: #f2f2f2; } a { color: #007BFF; text-decoration: none; } a:hover { text-decoration: underline; } </style> </head> <body> <h1>All Blog Posts</h1> <a href="add_blog.php">Add New Blog</a><br><br> <table> <tr><th>Title</th><th>Category</th><th>Created</th><th>Actions</th></tr> <?php foreach ($blogs as $row): ?> <tr> <td><?= htmlspecialchars($row['title']) ?></td> <td><?= htmlspecialchars($row['category'] ?? 'Uncategorized') ?></td> <td><?= date('Y-m-d', strtotime($row['created_at'])) ?></td> <td> <a href="edit_blog.php?id=<?= $row['id'] ?>">Edit</a> | <a href="delete_blog.php?id=<?= $row['id'] ?>" onclick="return confirm('Are you sure you want to delete this blog post?')">Delete</a> </td> </tr> <?php endforeach; ?> </table> </body> </html> dashboard.php 0000644 00000002174 15177072416 0007222 0 ustar 00 <?php session_start(); if (!isset($_SESSION['admin_id'])) { header('Location: login.php'); exit; } include '../db.php'; // <-- this line makes $pdo available // Add these queries: $totalCompanies = $pdo->query("SELECT COUNT(*) FROM companies")->fetchColumn(); $totalUsers = $pdo->query("SELECT COUNT(*) FROM users")->fetchColumn(); $totalReviews = $pdo->query("SELECT COUNT(*) FROM reviews")->fetchColumn(); $topCompany = $pdo->query(" SELECT c.name, ROUND(AVG(r.rating),1) AS avg_rating FROM companies c JOIN reviews r ON c.id=r.company_id GROUP BY c.id ORDER BY avg_rating DESC LIMIT 1 ")->fetch(); ?> <?php include 'menu.php'; ?> <!DOCTYPE html> <html> <head> <title>Dashboard</title> <link rel="stylesheet" href="../style.css"> </head> <body> <h2>Dashboard Stats</h2> <ul> <li>Total Companies: <?= $totalCompanies ?></li> <li>Total Users: <?= $totalUsers ?></li> <li>Total Reviews: <?= $totalReviews ?></li> <?php if($topCompany): ?> <li>Top Company: <?= htmlspecialchars($topCompany['name']) ?> (<?= $topCompany['avg_rating'] ?>/5)</li> <?php endif; ?> </ul> </body> </html>