This commit is contained in:
kirill.khorkov
2025-12-17 01:18:27 +03:00
parent 8a93cf8657
commit a7282f7363
394 changed files with 16013 additions and 146 deletions

View File

@@ -1,7 +1,7 @@
<?php
session_start();
require_once __DIR__ . '/../config/database.php';
require_once __DIR__ . '/config/database.php';
if (!isset($_SESSION['isLoggedIn']) || $_SESSION['isLoggedIn'] !== true) {
header('Location: login.php?error=auth_required&redirect=' . urlencode($_SERVER['REQUEST_URI']));
@@ -47,15 +47,8 @@ try {
$similarStmt->execute([$product['category_id'], $product_id]);
$similarProducts = $similarStmt->fetchAll();
$reviewsStmt = $db->prepare("
SELECT rating, comment, created_at
FROM reviews
WHERE product_id = ?
ORDER BY created_at DESC
LIMIT 5
");
$reviewsStmt->execute([$product_id]);
$reviews = $reviewsStmt->fetchAll();
// Отзывы временно отключены (таблица reviews не существует)
$reviews = [];
} catch (PDOException $e) {
die("Ошибка базы данных: " . $e->getMessage());
@@ -67,6 +60,7 @@ try {
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="/cite_practica/">
<title>AETERNA - <?= htmlspecialchars($product['name']) ?></title>
<link rel="stylesheet/less" type="text/css" href="style_for_cite.less">
<script src="https://cdn.jsdelivr.net/npm/less"></script>
@@ -148,7 +142,7 @@ try {
<div class="header__bottom">
<div class="container header__bottom-content">
<div class="catalog-menu">
<a href="/catalog.php" class="catalog-link active-catalog">
<a href="catalog.php" class="catalog-link active-catalog">
<div class="catalog-icon">
<span class="line"></span>
<span class="line"></span>
@@ -176,9 +170,9 @@ try {
<main class="container">
<div class="breadcrumbs">
<a href="cite_mebel.php">Главная</a> •
<a href="/catalog.php">Каталог</a> •
<a href="catalog.php">Каталог</a> •
<?php if ($product['category_name']): ?>
<a href="/catalog.php?category=<?= $product['category_id'] ?>">
<a href="catalog.php?category=<?= $product['category_id'] ?>">
<?= htmlspecialchars($product['category_name']) ?>
</a> •
<?php endif; ?>
@@ -188,7 +182,7 @@ try {
<div class="product__section">
<div class="product__gallery">
<div class="product__main-image">
<img src="<?= htmlspecialchars($product['image_url'] ?? 'img1/default.jpg') ?>"
<img src="<?= htmlspecialchars($product['image_url'] ?? 'img/1.jpg') ?>"
alt="<?= htmlspecialchars($product['name']) ?>"
id="mainImage">
</div>
@@ -295,7 +289,7 @@ try {
<?php if (isset($_SESSION['isAdmin']) && $_SESSION['isAdmin']): ?>
<div class="admin-actions" style="margin-top: 20px;">
<a href="admin_panel.php?action=edit&id=<?= $product['product_id'] ?>"
<a href="admin/index.php?action=edit_product&id=<?= $product['product_id'] ?>"
class="btn btn-warning">
<i class="fas fa-edit"></i> Редактировать
</a>
@@ -315,7 +309,7 @@ try {
<?php foreach ($similarProducts as $similar): ?>
<div class="product-card">
<div class="product-image">
<img src="<?= htmlspecialchars($similar['image_url'] ?? 'img2/default.jpg') ?>"
<img src="<?= htmlspecialchars($similar['image_url'] ?? 'img/1.jpg') ?>"
alt="<?= htmlspecialchars($similar['name']) ?>">
</div>
<div class="product-info">
@@ -323,7 +317,7 @@ try {
<p class="product-price">
<?= number_format($similar['price'], 0, '', ' ') ?> ₽
</p>
<a href="product_page.php?id=<?= $similar['product_id'] ?>"
<a href="product.php?id=<?= $similar['product_id'] ?>"
class="btn btn-primary">
Подробнее
</a>
@@ -344,7 +338,7 @@ try {
<div class="footer__col">
<h5>ПОКУПАТЕЛЮ</h5>
<ul>
<li><a href="/catalog.php">Каталог</a></li>
<li><a href="catalog.php">Каталог</a></li>
<li><a href="services.php">Услуги</a></li>
</ul>
</div>
@@ -407,7 +401,7 @@ $(document).ready(function() {
const quantity = $('.product__qty-value').val();
$.ajax({
url: 'add_to_cart.php',
url: 'api/add_to_cart.php',
method: 'POST',
data: {
product_id: productId,
@@ -434,7 +428,7 @@ $(document).ready(function() {
const quantity = $('.product__qty-value').val();
$.ajax({
url: 'add_to_cart.php',
url: 'api/add_to_cart.php',
method: 'POST',
data: {
product_id: productId,
@@ -465,17 +459,8 @@ $(document).ready(function() {
window.deleteProduct = function(productId) {
if (confirm('Вы уверены, что хотите удалить этот товар?')) {
$.ajax({
url: 'catalog_admin_action.php',
method: 'POST',
data: {
action: 'delete',
product_id: productId
},
success: function() {
window.location.href = 'catalog.php';
}
});
// Redirect to admin panel for deletion
window.location.href = 'admin/index.php?action=products';
}
};
});