Fix
This commit is contained in:
45
public/admin/fix_delete_category.php
Normal file
45
public/admin/fix_delete_category.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
session_start();
|
||||
require_once __DIR__ . '/../config/database.php';
|
||||
|
||||
// Проверка прав администратора
|
||||
if (!isset($_SESSION['isAdmin']) || !$_SESSION['isAdmin']) {
|
||||
echo json_encode(['success' => false, 'message' => 'Доступ запрещен']);
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$categoryId = $_POST['category_id'] ?? 0;
|
||||
|
||||
if (!$categoryId) {
|
||||
echo json_encode(['success' => false, 'message' => 'Категория не указана']);
|
||||
exit();
|
||||
}
|
||||
|
||||
try {
|
||||
$db = Database::getInstance()->getConnection();
|
||||
|
||||
// Проверяем, есть ли товары в этой категории
|
||||
$checkStmt = $db->prepare("SELECT COUNT(*) FROM products WHERE category_id = ?");
|
||||
$checkStmt->execute([$categoryId]);
|
||||
$productCount = $checkStmt->fetchColumn();
|
||||
|
||||
if ($productCount > 0) {
|
||||
echo json_encode(['success' => false, 'message' => 'Нельзя удалить категорию с товарами. Сначала удалите или переместите товары.']);
|
||||
exit();
|
||||
}
|
||||
|
||||
// Удаляем категорию
|
||||
$stmt = $db->prepare("DELETE FROM categories WHERE category_id = ?");
|
||||
$stmt->execute([$categoryId]);
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Категория удалена']);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Ошибка базы данных: ' . $e->getMessage()]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => 'Неверный запрос']);
|
||||
}
|
||||
|
||||
@@ -301,6 +301,7 @@ try {
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="/cite_practica/admin/">
|
||||
<title>AETERNA - Админ-панель</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
<style>
|
||||
@@ -333,25 +334,25 @@ try {
|
||||
<h1><i class="fas fa-user-shield"></i> Админ-панель AETERNA</h1>
|
||||
<div>
|
||||
<span><?= htmlspecialchars($_SESSION['user_email'] ?? 'Администратор') ?></span>
|
||||
<a href="../catalog.php" class="btn btn-primary" style="margin-left: 10px;">В каталог</a>
|
||||
<a href="../logout.php" class="btn btn-danger" style="margin-left: 10px;">Выйти</a>
|
||||
<a href="/cite_practica/catalog.php" class="btn btn-primary" style="margin-left: 10px;">В каталог</a>
|
||||
<a href="/cite_practica/logout.php" class="btn btn-danger" style="margin-left: 10px;">Выйти</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-tabs">
|
||||
<a href="?action=dashboard" class="admin-tab <?= $action == 'dashboard' ? 'active' : '' ?>">
|
||||
<a href="index.php?action=dashboard" class="admin-tab <?= $action == 'dashboard' ? 'active' : '' ?>">
|
||||
<i class="fas fa-tachometer-alt"></i> Дашборд
|
||||
</a>
|
||||
<a href="?action=products" class="admin-tab <?= $action == 'products' ? 'active' : '' ?>">
|
||||
<a href="index.php?action=products" class="admin-tab <?= $action == 'products' ? 'active' : '' ?>">
|
||||
<i class="fas fa-box"></i> Товары
|
||||
</a>
|
||||
<a href="?action=categories" class="admin-tab <?= $action == 'categories' ? 'active' : '' ?>">
|
||||
<a href="index.php?action=categories" class="admin-tab <?= $action == 'categories' ? 'active' : '' ?>">
|
||||
<i class="fas fa-tags"></i> Категории
|
||||
</a>
|
||||
<a href="?action=orders" class="admin-tab <?= $action == 'orders' ? 'active' : '' ?>">
|
||||
<a href="index.php?action=orders" class="admin-tab <?= $action == 'orders' ? 'active' : '' ?>">
|
||||
<i class="fas fa-shopping-cart"></i> Заказы
|
||||
</a>
|
||||
<a href="?action=users" class="admin-tab <?= $action == 'users' ? 'active' : '' ?>">
|
||||
<a href="index.php?action=users" class="admin-tab <?= $action == 'users' ? 'active' : '' ?>">
|
||||
<i class="fas fa-users"></i> Пользователи
|
||||
</a>
|
||||
</div>
|
||||
@@ -392,10 +393,10 @@ try {
|
||||
</div>
|
||||
|
||||
<div style="text-align: center; margin: 40px 0;">
|
||||
<a href="?action=add_product" class="btn btn-success" style="padding: 15px 30px; font-size: 16px;">
|
||||
<a href="index.php?action=add_product" class="btn btn-success" style="padding: 15px 30px; font-size: 16px;">
|
||||
<i class="fas fa-plus"></i> Добавить новый товар
|
||||
</a>
|
||||
<a href="?action=add_category" class="btn btn-primary" style="padding: 15px 30px; font-size: 16px;">
|
||||
<a href="index.php?action=add_category" class="btn btn-primary" style="padding: 15px 30px; font-size: 16px;">
|
||||
<i class="fas fa-plus"></i> Добавить категорию
|
||||
</a>
|
||||
</div>
|
||||
@@ -405,13 +406,13 @@ try {
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
|
||||
<h2>Управление товарами</h2>
|
||||
<div>
|
||||
<a href="?action=add_product" class="btn btn-success">
|
||||
<a href="index.php?action=add_product" class="btn btn-success">
|
||||
<i class="fas fa-plus"></i> Добавить товар
|
||||
</a>
|
||||
<?php if (isset($_GET['show_all'])): ?>
|
||||
<a href="?action=products" class="btn btn-primary">Только активные</a>
|
||||
<a href="index.php?action=products" class="btn btn-primary">Только активные</a>
|
||||
<?php else: ?>
|
||||
<a href="?action=products&show_all=1" class="btn btn-primary">Показать все</a>
|
||||
<a href="index.php?action=products&show_all=1" class="btn btn-primary">Показать все</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -446,7 +447,7 @@ try {
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="action-buttons">
|
||||
<a href="?action=edit_product&id=<?= $product['product_id'] ?>" class="btn btn-warning btn-sm">
|
||||
<a href="index.php?action=edit_product&id=<?= $product['product_id'] ?>" class="btn btn-warning btn-sm">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
<?php if ($product['is_available']): ?>
|
||||
@@ -478,7 +479,7 @@ try {
|
||||
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
|
||||
<h2>Управление категориями</h2>
|
||||
<a href="?action=add_category" class="btn btn-success">
|
||||
<a href="index.php?action=add_category" class="btn btn-success">
|
||||
<i class="fas fa-plus"></i> Добавить категорию
|
||||
</a>
|
||||
</div>
|
||||
@@ -504,7 +505,7 @@ try {
|
||||
<td><?= $category['product_count'] ?></td>
|
||||
<td class="action-buttons">
|
||||
|
||||
<a href="?action=edit_category&id=<?= $category['category_id'] ?>" class="btn btn-warning btn-sm">
|
||||
<a href="index.php?action=edit_category&id=<?= $category['category_id'] ?>" class="btn btn-warning btn-sm">
|
||||
<i class="fas fa-edit"></i> Редактировать
|
||||
</a>
|
||||
|
||||
@@ -621,7 +622,7 @@ try {
|
||||
<button type="submit" class="btn btn-success">
|
||||
<?= $action == 'add_product' ? 'Добавить товар' : 'Сохранить изменения' ?>
|
||||
</button>
|
||||
<a href="?action=products" class="btn btn-primary">Отмена</a>
|
||||
<a href="index.php?action=products" class="btn btn-primary">Отмена</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -680,7 +681,7 @@ try {
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<?= $action == 'add_category' ? 'Добавить категорию' : 'Сохранить изменения' ?>
|
||||
</button>
|
||||
<a href="?action=categories" class="btn">Отмена</a>
|
||||
<a href="index.php?action=categories" class="btn">Отмена</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -707,7 +708,7 @@ try {
|
||||
<td><?= htmlspecialchars($order['status']) ?></td>
|
||||
<td><?= date('d.m.Y H:i', strtotime($order['created_at'])) ?></td>
|
||||
<td>
|
||||
<a href="?action=order_details&id=<?= $order['order_id'] ?>" class="btn btn-primary btn-sm">
|
||||
<a href="index.php?action=order_details&id=<?= $order['order_id'] ?>" class="btn btn-primary btn-sm">
|
||||
<i class="fas fa-eye"></i>
|
||||
</a>
|
||||
</td>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
session_start();
|
||||
require_once __DIR__ . '/../config/database.php';
|
||||
|
||||
@@ -61,8 +61,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
$orderStmt = $db->prepare("
|
||||
INSERT INTO orders (
|
||||
user_id, order_number, total_amount, discount_amount,
|
||||
delivery_cost, final_amount, status, payment_method,
|
||||
user_id, order_number, subtotal, discount_amount,
|
||||
delivery_price, final_amount, status, payment_method,
|
||||
delivery_method, delivery_address, customer_name,
|
||||
customer_email, customer_phone, notes
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
@@ -83,7 +83,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$itemStmt = $db->prepare("
|
||||
INSERT INTO order_items (
|
||||
order_id, product_id, product_name,
|
||||
quantity, unit_price, total_price
|
||||
quantity, product_price, total_price
|
||||
) VALUES (?, ?, ?, ?, ?, ?)
|
||||
");
|
||||
|
||||
|
||||
@@ -27,7 +27,12 @@ $(document).ready(function() {
|
||||
$('.products-total').text(productsTotal + ' ₽');
|
||||
$('.summary-count').text(totalCount);
|
||||
$('.total-count').text(totalCount + ' шт.');
|
||||
$('.cart-count').text(totalCount);
|
||||
if ($('.cart-count').length) {
|
||||
$('.cart-count').text(totalCount);
|
||||
}
|
||||
if ($('#cartCount').length) {
|
||||
$('#cartCount').text(totalCount);
|
||||
}
|
||||
|
||||
const finalTotal = productsTotal + cart.delivery - cart.discount;
|
||||
$('.final-total').text(finalTotal + ' ₽');
|
||||
@@ -282,13 +287,46 @@ $(document).ready(function() {
|
||||
return;
|
||||
}
|
||||
|
||||
$(this).prop('disabled', true).text('ОБРАБОТКА...');
|
||||
const $btn = $(this);
|
||||
$btn.prop('disabled', true).text('ОБРАБОТКА...');
|
||||
|
||||
setTimeout(() => {
|
||||
showMessage('#order-success', 5000);
|
||||
$(this).prop('disabled', false).text('ОФОРМИТЬ ЗАКАЗ');
|
||||
// Собрать данные заказа
|
||||
const orderData = {
|
||||
full_name: $('#fullname').val().trim(),
|
||||
phone: $('#phone').val().trim(),
|
||||
email: $('#email').val().trim(),
|
||||
region: $('#region').val().trim(),
|
||||
address: $('#address').val().trim(),
|
||||
delivery_method: $('input[name="delivery"]:checked').val(),
|
||||
comment: $('#comment').val().trim()
|
||||
};
|
||||
|
||||
}, 2000);
|
||||
// Отправить на сервер
|
||||
$.ajax({
|
||||
url: 'api/process_order.php',
|
||||
method: 'POST',
|
||||
data: orderData,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
showMessage('#order-success', 5000);
|
||||
$('#order-success').text('Заказ успешно оформлен! Номер заказа: ' + (response.order_id || ''));
|
||||
// Очистить корзину и форму
|
||||
setTimeout(() => {
|
||||
window.location.href = 'catalog.php';
|
||||
}, 2000);
|
||||
} else {
|
||||
showMessage('#form-error', 5000);
|
||||
$('#form-error').text(response.message || 'Ошибка оформления заказа').removeClass('success').addClass('error');
|
||||
$btn.prop('disabled', false).text('ОФОРМИТЬ ЗАКАЗ');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
showMessage('#form-error', 5000);
|
||||
$('#form-error').text('Ошибка сервера. Попробуйте позже.').removeClass('success').addClass('error');
|
||||
$btn.prop('disabled', false).text('ОФОРМИТЬ ЗАКАЗ');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#phone').on('input', function() {
|
||||
|
||||
@@ -226,7 +226,7 @@ $(document).ready(function() {
|
||||
$('.login-btn').on('click', function() {
|
||||
showMessage('warning', 'Переход к форме входа...');
|
||||
setTimeout(() => {
|
||||
window.location.href = 'вход.php';
|
||||
window.location.href = 'login.php';
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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']));
|
||||
@@ -156,6 +156,7 @@ try {
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<base href="/cite_practica/">
|
||||
<title>AETERNA - Каталог</title>
|
||||
<link rel="stylesheet/less" type="text/css" href="style_for_cite.less">
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
@@ -735,9 +736,9 @@ try {
|
||||
Все категории <span>▼</span>
|
||||
<div class="catalog-dropdown__menu">
|
||||
<ul>
|
||||
<li><a href="/catalog.php">Все товары</a></li>
|
||||
<li><a href="catalog.php">Все товары</a></li>
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<li><a href="/catalog.php?category=<?= $category['category_id'] ?>">
|
||||
<li><a href="catalog.php?category=<?= $category['category_id'] ?>">
|
||||
<?= htmlspecialchars($category['name']) ?>
|
||||
</a></li>
|
||||
<?php endforeach; ?>
|
||||
@@ -811,7 +812,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>
|
||||
@@ -899,12 +900,12 @@ try {
|
||||
<i class="fas fa-eye"></i> Настройки отображения
|
||||
</h4>
|
||||
<?php if ($show_all): ?>
|
||||
<a href="/catalog.php?<?= http_build_query(array_merge($_GET, ['show_all' => 0])) ?>"
|
||||
<a href="catalog.php?<?= http_build_query(array_merge($_GET, ['show_all' => 0])) ?>"
|
||||
class="btn btn-primary" style="background: #453227; color: white; padding: 8px 15px; border-radius: 4px; text-decoration: none; display: inline-block;">
|
||||
<i class="fas fa-eye-slash"></i> Скрыть недоступные товары
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a href="/catalog.php?<?= http_build_query(array_merge($_GET, ['show_all' => 1])) ?>"
|
||||
<a href="catalog.php?<?= http_build_query(array_merge($_GET, ['show_all' => 1])) ?>"
|
||||
class="btn btn-info" style="background: #17a2b8; color: white; padding: 8px 15px; border-radius: 4px; text-decoration: none; display: inline-block;">
|
||||
<i class="fas fa-eye"></i> Показать все товары
|
||||
</a>
|
||||
@@ -943,13 +944,13 @@ try {
|
||||
<div class="filter-group">
|
||||
<h4 class="filter-title">КАТЕГОРИИ</h4>
|
||||
<ul class="filter-list">
|
||||
<li><a href="/catalog.php<?= $show_all ? '?show_all=1' : '' ?>"
|
||||
<li><a href="catalog.php<?= $show_all ? '?show_all=1' : '' ?>"
|
||||
class="<?= !$category_id ? 'active-category' : '' ?>">
|
||||
Все товары
|
||||
</a></li>
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<li>
|
||||
<a href="/catalog.php?category=<?= $category['category_id'] ?><?= $show_all ? '&show_all=1' : '' ?>"
|
||||
<a href="catalog.php?category=<?= $category['category_id'] ?><?= $show_all ? '&show_all=1' : '' ?>"
|
||||
class="<?= $category_id == $category['category_id'] ? 'active-category' : '' ?>">
|
||||
<?= htmlspecialchars($category['name']) ?>
|
||||
</a>
|
||||
@@ -963,7 +964,7 @@ try {
|
||||
<h4 class="filter-title">ПОДКАТЕГОРИИ</h4>
|
||||
<ul class="filter-list">
|
||||
<?php foreach ($subcategories as $sub): ?>
|
||||
<li><a href="/catalog.php?category=<?= $category_id ?>&subcategory=<?= $sub['subcategory_id'] ?><?= $show_all ? '&show_all=1' : '' ?>">
|
||||
<li><a href="catalog.php?category=<?= $category_id ?>&subcategory=<?= $sub['subcategory_id'] ?><?= $show_all ? '&show_all=1' : '' ?>">
|
||||
<?= htmlspecialchars($sub['name']) ?>
|
||||
</a></li>
|
||||
<?php endforeach; ?>
|
||||
@@ -1043,7 +1044,7 @@ try {
|
||||
<?php if ($search): ?>
|
||||
<p style="color: #666;">
|
||||
Результаты поиска по запросу: "<strong><?= htmlspecialchars($search) ?></strong>"
|
||||
<a href="/catalog.php<?= $show_all ? '?show_all=1' : '' ?>" style="margin-left: 10px; color: #617365; text-decoration: none;">
|
||||
<a href="catalog.php<?= $show_all ? '?show_all=1' : '' ?>" style="margin-left: 10px; color: #617365; text-decoration: none;">
|
||||
<i class="fas fa-times"></i> Очистить поиск
|
||||
</a>
|
||||
</p>
|
||||
@@ -1112,7 +1113,7 @@ try {
|
||||
data-product-id="<?= $productId ?>"
|
||||
data-available="<?= $product['is_available'] && $product['stock_quantity'] > 0 ? 'true' : 'false' ?>">
|
||||
<div class="product-image-container">
|
||||
<img src="<?= htmlspecialchars($product['image_url'] ?? 'img2/default.jpg') ?>"
|
||||
<img src="<?= htmlspecialchars($product['image_url'] ?? 'img/1.jpg') ?>"
|
||||
alt="<?= htmlspecialchars($product['name']) ?>"
|
||||
class="<?= strpos($sizeClass, 'small1') !== false ? 'product-img1' : 'product-img' ?>">
|
||||
|
||||
@@ -1145,7 +1146,7 @@ try {
|
||||
<div class="footer__col">
|
||||
<h5 style="color: #453227;">ПОКУПАТЕЛЮ</h5>
|
||||
<ul>
|
||||
<li><a href="/catalog.php" style="color: #453227;">Каталог</a></li>
|
||||
<li><a href="catalog.php" style="color: #453227;">Каталог</a></li>
|
||||
<li><a href="services.php" style="color: #453227;">Услуги</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -1226,12 +1227,7 @@ try {
|
||||
const isAvailable = $(this).data('available');
|
||||
|
||||
if (isAvailable) {
|
||||
|
||||
if (productId == 2) {
|
||||
window.location.href = 'product_modern.php';
|
||||
} else {
|
||||
window.location.href = 'product_detail.php?id=' + productId;
|
||||
}
|
||||
window.location.href = 'product.php?id=' + productId;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
checkAuthStatus();
|
||||
|
||||
$('#loginForm').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const email = $('#login-email').val();
|
||||
const password = $('#login-password').val();
|
||||
const remember = $('#remember').is(':checked');
|
||||
|
||||
$.ajax({
|
||||
url: 'login_handler.php',
|
||||
method: 'POST',
|
||||
data: {
|
||||
email: email,
|
||||
password: password
|
||||
},
|
||||
success: function(response) {
|
||||
try {
|
||||
const result = JSON.parse(response);
|
||||
if (result.success) {
|
||||
|
||||
if (remember) {
|
||||
localStorage.setItem('rememberedEmail', email);
|
||||
} else {
|
||||
localStorage.removeItem('rememberedEmail');
|
||||
}
|
||||
|
||||
window.location.href = result.redirect || 'catalog.php';
|
||||
} else {
|
||||
showMessage('error', result.message || 'Ошибка авторизации');
|
||||
}
|
||||
} catch(e) {
|
||||
showMessage('error', 'Ошибка обработки ответа');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
showMessage('error', 'Ошибка сервера');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function checkAuthStatus() {
|
||||
$.ajax({
|
||||
url: 'check_auth_status.php',
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
try {
|
||||
const result = JSON.parse(response);
|
||||
if (result.loggedIn) {
|
||||
updateUserProfile(result.user);
|
||||
}
|
||||
} catch(e) {
|
||||
console.error('Ошибка проверки авторизации', e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateUserProfile(user) {
|
||||
|
||||
if ($('#userEmail').length) {
|
||||
$('#userEmail').text(user.email);
|
||||
}
|
||||
if ($('#userName').length) {
|
||||
$('#userName').text(user.full_name);
|
||||
}
|
||||
}
|
||||
|
||||
function showMessage(type, text) {
|
||||
const $message = $('#' + type + 'Message');
|
||||
if ($message.length) {
|
||||
$message.text(text).fadeIn();
|
||||
setTimeout(() => $message.fadeOut(), 5000);
|
||||
} else {
|
||||
alert(text);
|
||||
}
|
||||
}
|
||||
|
||||
function checkAuth(redirectUrl) {
|
||||
$.ajax({
|
||||
url: 'check_auth_status.php',
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
try {
|
||||
const result = JSON.parse(response);
|
||||
if (result.loggedIn) {
|
||||
window.location.href = redirectUrl;
|
||||
} else {
|
||||
|
||||
showLoginModal(redirectUrl);
|
||||
}
|
||||
} catch(e) {
|
||||
showLoginModal(redirectUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function showLoginModal(redirectUrl) {
|
||||
|
||||
window.location.href = 'вход.php?redirect=' + encodeURIComponent(redirectUrl);
|
||||
}
|
||||
});
|
||||
@@ -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');
|
||||
@@ -47,6 +47,7 @@ try {
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="/cite_practica/">
|
||||
<title>AETERNA - Оформление заказа</title>
|
||||
<link rel="stylesheet/less" type="text/css" href="style_for_cite.less">
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
@@ -99,7 +100,7 @@ try {
|
||||
<i class="fas fa-shopping-cart" style="font-size: 48px; color: #ccc; margin-bottom: 20px;"></i>
|
||||
<p>Ваша корзина пуста</p>
|
||||
<div class="continue-shopping">
|
||||
<a href="/catalog.php" class="btn">Продолжить покупки</a>
|
||||
<a href="catalog.php" class="btn">Продолжить покупки</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
@@ -107,7 +108,7 @@ try {
|
||||
<?php foreach ($cart_items as $item): ?>
|
||||
<div class="products__item" data-product-id="<?= $item['product_id'] ?>" data-price="<?= $item['price'] ?>">
|
||||
<div class="products__image">
|
||||
<img src="<?= htmlspecialchars($item['image_url'] ?? 'img1/default.jpg') ?>"
|
||||
<img src="<?= htmlspecialchars($item['image_url'] ?? 'img/1.jpg') ?>"
|
||||
alt="<?= htmlspecialchars($item['name']) ?>"
|
||||
class="product-img">
|
||||
</div>
|
||||
@@ -283,7 +284,7 @@ if (file_exists('footer.php')) {
|
||||
<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>
|
||||
|
||||
760
public/cite_mebel.php
Normal file
760
public/cite_mebel.php
Normal file
@@ -0,0 +1,760 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if (isset($_GET['action']) && $_GET['action'] == 'go_to_catalog') {
|
||||
if (!isset($_SESSION['isLoggedIn']) || $_SESSION['isLoggedIn'] !== true) {
|
||||
|
||||
header('Location: login.php?redirect=' . urlencode('catalog.php'));
|
||||
exit();
|
||||
} else {
|
||||
|
||||
header('Location: catalog.php');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<base href="/cite_practica/">
|
||||
<title>AETERNA - Мебель и Интерьер</title>
|
||||
<link rel="stylesheet/less" type="text/css" href="style_for_cite.less">
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
<style>
|
||||
|
||||
.user-profile-dropdown {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.user-profile-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
cursor: pointer;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.user-profile-toggle:hover {
|
||||
background-color: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.user-avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, #617365 0%, #453227 100%);
|
||||
color: white;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.user-email {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
max-width: 120px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.user-status {
|
||||
font-size: 10px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 12px;
|
||||
text-transform: uppercase;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.user-status.admin {
|
||||
background-color: #617365;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.user-status.user {
|
||||
background-color: #28a745;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.dropdown-arrow {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.user-profile-menu {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
background: white;
|
||||
min-width: 280px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 5px 20px rgba(0,0,0,0.15);
|
||||
z-index: 1000;
|
||||
padding-top: 10px;
|
||||
border: 1px solid #e0e0e0;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.user-profile-menu::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 10px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.user-profile-dropdown:hover .user-profile-menu {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.user-profile-header {
|
||||
padding: 15px;
|
||||
background: #f8f9fa;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
}
|
||||
|
||||
.user-profile-name {
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
color: #333;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.user-profile-details {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.user-profile-details small {
|
||||
display: block;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.user-profile-details i {
|
||||
width: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.user-profile-links {
|
||||
list-style: none;
|
||||
padding: 10px 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.user-profile-links li {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.user-profile-links a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 15px;
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
transition: all 0.3s ease;
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
|
||||
.user-profile-links a:hover {
|
||||
background-color: #f5f5f5;
|
||||
border-left-color: #453227;
|
||||
color: #453227;
|
||||
}
|
||||
|
||||
.user-profile-links i {
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logout-item {
|
||||
border-top: 1px solid #e0e0e0;
|
||||
margin-top: 5px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.logout-link {
|
||||
color: #dc3545 !important;
|
||||
}
|
||||
|
||||
.logout-link:hover {
|
||||
background-color: #ffe6e6 !important;
|
||||
border-left-color: #dc3545 !important;
|
||||
}
|
||||
|
||||
.cart-icon {
|
||||
position: relative;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.cart-count {
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
right: -8px;
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
border-radius: 50%;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
font-size: 11px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.link-disabled {
|
||||
cursor: not-allowed !important;
|
||||
opacity: 0.6 !important;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.link-disabled:hover::after {
|
||||
content: "🔒 Требуется авторизация";
|
||||
position: absolute;
|
||||
top: -30px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: #333;
|
||||
color: white;
|
||||
padding: 5px 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.catalog-locked {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.catalog-locked::before {
|
||||
content: "🔒";
|
||||
position: absolute;
|
||||
top: -5px;
|
||||
right: -5px;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header class="header">
|
||||
<div class="header__top">
|
||||
<div class="container header__top-content">
|
||||
<div class="logo">AETERNA</div>
|
||||
|
||||
<div class="search-catalog">
|
||||
<div class="catalog-dropdown">
|
||||
Все категории <span>▼</span>
|
||||
<div class="catalog-dropdown__menu">
|
||||
<ul>
|
||||
<li><a href="javascript:void(0)" onclick="checkAuth('catalog.php?category=1')">Диваны</a></li>
|
||||
<li><a href="javascript:void(0)" onclick="checkAuth('catalog.php?category=2')">Кровати</a></li>
|
||||
<li><a href="javascript:void(0)" onclick="checkAuth('catalog.php?category=3')">Шкафы</a></li>
|
||||
<li><a href="javascript:void(0)" onclick="checkAuth('catalog.php?category=4')">Стулья</a></li>
|
||||
<li><a href="javascript:void(0)" onclick="checkAuth('catalog.php?category=5')">Столы</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-box">
|
||||
<input type="text" placeholder="Поиск товаров" id="searchInput">
|
||||
<span class="search-icon"><i class="fas fa-search"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header__icons--top">
|
||||
<?php if (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] === true): ?>
|
||||
|
||||
<a href="checkout.php" class="icon cart-icon">
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
<span class="cart-count">0</span>
|
||||
</a>
|
||||
|
||||
<div class="user-profile-dropdown">
|
||||
<div class="user-profile-toggle">
|
||||
<div class="user-avatar">
|
||||
<?php
|
||||
$email = $_SESSION['user_email'] ?? '';
|
||||
echo !empty($email) ? strtoupper(substr($email, 0, 1)) : 'U';
|
||||
?>
|
||||
</div>
|
||||
<div class="user-info">
|
||||
<div class="user-email"><?= htmlspecialchars($email) ?></div>
|
||||
<div class="user-status <?= isset($_SESSION['isAdmin']) && $_SESSION['isAdmin'] ? 'admin' : 'user' ?>">
|
||||
<?= isset($_SESSION['isAdmin']) && $_SESSION['isAdmin'] ? 'Админ' : 'Пользователь' ?>
|
||||
</div>
|
||||
</div>
|
||||
<i class="fas fa-chevron-down dropdown-arrow"></i>
|
||||
</div>
|
||||
|
||||
<div class="user-profile-menu">
|
||||
<div class="user-profile-header">
|
||||
<div class="user-profile-name">
|
||||
<i class="fas fa-user"></i>
|
||||
<?= htmlspecialchars($_SESSION['full_name'] ?? $email) ?>
|
||||
</div>
|
||||
<div class="user-profile-details">
|
||||
<small><i class="far fa-envelope"></i> <?= htmlspecialchars($email) ?></small>
|
||||
<?php if (isset($_SESSION['login_time'])): ?>
|
||||
<small><i class="far fa-clock"></i> Вошел: <?= date('d.m.Y H:i', $_SESSION['login_time']) ?></small>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="user-profile-links">
|
||||
<li>
|
||||
<a href="register.php">
|
||||
<i class="fas fa-user-cog"></i>
|
||||
<span>Настройки профиля</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="checkout.php">
|
||||
<i class="fas fa-shopping-bag"></i>
|
||||
<span>Мои заказы</span>
|
||||
</a>
|
||||
</li>
|
||||
<?php if (isset($_SESSION['isAdmin']) && $_SESSION['isAdmin']): ?>
|
||||
<li>
|
||||
<a href="catalog_admin.php">
|
||||
<i class="fas fa-user-shield"></i>
|
||||
<span>Панель администратора</span>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<li class="logout-item">
|
||||
<a href="logout.php" class="logout-link">
|
||||
<i class="fas fa-sign-out-alt"></i>
|
||||
<span>Выйти из аккаунта</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<a href="login.php" class="icon">
|
||||
<i class="far fa-user"></i>
|
||||
</a>
|
||||
<a href="login.php" style="font-size: 12px; color: #666; margin-left: 5px;">
|
||||
Войти
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header__bottom">
|
||||
<div class="container header__bottom-content">
|
||||
<div class="catalog-menu">
|
||||
<a href="catalog.php"
|
||||
class="catalog-link <?= (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] === true) ? '' : 'catalog-locked' ?>">
|
||||
<div class="catalog-icon">
|
||||
<span class="line"></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"></span>
|
||||
</div>
|
||||
<span class="catalog-lines">☰</span>
|
||||
Каталог
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<nav class="nav">
|
||||
<ul class="nav-list">
|
||||
<li><a href="cite_mebel.php" class="active">Главная</a></li>
|
||||
<li><a href="services.php">Услуги</a></li>
|
||||
<li><a href="delivery.php">Доставка и оплата</a></li>
|
||||
<li><a href="warranty.php">Гарантия</a></li>
|
||||
<li><a href="#footer">Контакты</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="header-phone">+7(912)999-12-23</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<section class="hero">
|
||||
<div class="container hero__content">
|
||||
<div class="hero__image-block">
|
||||
<div class="hero__circle"></div>
|
||||
<img src="img/chair.PNG" alt="Кресло и торшер" class="hero__img">
|
||||
</div>
|
||||
<div class="hero__text-block">
|
||||
<h1>ДОБАВЬТЕ ИЗЫСКАННОСТИ В СВОЙ ИНТЕРЬЕР</h1>
|
||||
<p class="hero__usp-text">Мы создаем мебель, которая сочетает в себе безупречный дизайн, натуральные материалы, продуманный функционал, чтобы ваш день начинался и заканчивался с комфортом.</p>
|
||||
|
||||
<?php if (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] === true): ?>
|
||||
<a href="?action=go_to_catalog" class="btn primary-btn">ПЕРЕЙТИ В КАТАЛОГ</a>
|
||||
<?php else: ?>
|
||||
<a href="javascript:void(0)" onclick="checkAuth('catalog.php')" class="btn primary-btn link-disabled">ПЕРЕЙТИ В КАТАЛОГ</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="advantages">
|
||||
<div class="container">
|
||||
<div class="advantages__header">
|
||||
<h2>ПОЧЕМУ <br>ВЫБИРАЮТ НАС?</h2>
|
||||
<div class="advantages__items">
|
||||
<div class="advantage-item">
|
||||
<span class="advantage-item__number">1</span>
|
||||
<h4>ГАРАНТИЯ ВЫСОЧАЙШЕГО КАЧЕСТВА</h4>
|
||||
<p>Собственное производство и строгий контроль на всех этапах.</p>
|
||||
</div>
|
||||
<div class="advantage-item">
|
||||
<span class="advantage-item__number">2</span>
|
||||
<h4>ИСПОЛЬЗОВАНИЕ НАДЕЖНЫХ МАТЕРИАЛОВ</h4>
|
||||
<p>Гарантия безопасности и долговечности.</p>
|
||||
</div>
|
||||
<div class="advantage-item">
|
||||
<span class="advantage-item__number">3</span>
|
||||
<h4>ИНДИВИДУАЛЬНЫЙ ПОДХОД И ГИБКОСТЬ УСЛОВИЙ</h4>
|
||||
<p>Реализуем проекты любой сложности по вашим техническим заданиям.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="promo-images">
|
||||
<div class="promo-image-col">
|
||||
<img src="img/спальня.jpg" alt="Кровать и тумба">
|
||||
<div class="image-overlay-text">
|
||||
<h4>НОВИНКИ В КАТЕГОРИЯХ <br>МЯГКАЯ МЕБЕЛЬ</h4>
|
||||
<a href="#" class="overlay-link">ПЕРЕЙТИ</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="promo-image-col">
|
||||
<img src="img/диван.jpg" alt="Диван в гостиной">
|
||||
<div class="image-overlay-text">
|
||||
<h4>РАСПРОДАЖА <br>ПРЕДМЕТЫ ДЕКОРА</h4>
|
||||
<a href="#" class="overlay-link">ПЕРЕЙТИ</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="about">
|
||||
<div class="container about__content">
|
||||
<div class="about__column about__column--left">
|
||||
<div class="about__text-block">
|
||||
<h2>О НАС</h2>
|
||||
<p class="text-justified">Компания AETERNA - российский производитель качественной корпусной и мягкой мебели для дома и офиса. С 2015 года мы успешно реализуем проекты любой сложности, сочетая современные технологии, проверенные материалы и классическое мастерство.</p>
|
||||
</div>
|
||||
<img src="img/кресло_1.jpg" alt="Фиолетовое кресло" class="about__img about__img--small">
|
||||
</div>
|
||||
|
||||
<div class="about__column about__column--right">
|
||||
<img src="img/диван_1.jpg" alt="Белый диван с подушками" class="about__img about__img--large">
|
||||
<p class="about__caption">Наша сеть включает 30+ российских фабрик, отобранных по строгим стандартам качества. Мы сотрудничаем исключительно с лидерами рынка, чья продукция доказала свое превосходство временем.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="solutions">
|
||||
<div class="container">
|
||||
<div class="solutions-slider">
|
||||
<div class="solutions-slider__slides">
|
||||
<div class="solutions-slider__slide">
|
||||
<img src="img/слайдер_1.jpg" class="solution-img" alt="Готовое решение для гостиной">
|
||||
<div class="solution-text-overlay">
|
||||
<h2>ГОТОВОЕ РЕШЕНИЕ<br>ДЛЯ ВАШЕЙ ГОСТИНОЙ</h2> <br>
|
||||
<p>УСПЕЙТЕ ЗАКАЗАТЬ СЕЙЧАС</p>
|
||||
</div>
|
||||
<a href="#" class="solution-image-link">Подробнее</a>
|
||||
</div>
|
||||
|
||||
<div class="solutions-slider__slide">
|
||||
<img src="img/слайдер_6.jpg" class="solution-img" alt="Готовое решение для спальни">
|
||||
<div class="solution-text-overlay">
|
||||
<h2>ГОТОВОЕ РЕШЕНИЕ<br>ДЛЯ ВАШЕЙ СПАЛЬНИ</h2> <br>
|
||||
<p>УСПЕЙТЕ ЗАКАЗАТЬ СЕЙЧАС</p>
|
||||
</div>
|
||||
<a href="#" class="solution-image-link">Подробнее</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="stats">
|
||||
<div class="container">
|
||||
<div class="stats__items">
|
||||
<div class="stat-item">
|
||||
<div class="stat-number">10+</div>
|
||||
<div class="stat-label">Лет работы</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-number">30 000+</div>
|
||||
<div class="stat-label">Довольных покупателей</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-number">4500+</div>
|
||||
<div class="stat-label">Реализованных заказов</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="faq" id="faq">
|
||||
<div class="container">
|
||||
<h2>ОТВЕТЫ НА ВОПРОСЫ</h2>
|
||||
<div class="faq__items">
|
||||
<div class="faq-item">
|
||||
<span class="number-circle">1</span>
|
||||
<div class="faq-item__content">
|
||||
<h4>Сколько времени занимает доставка?</h4>
|
||||
<p>Доставка готовых позиций занимает 1-3 дня. Мебель на заказ изготавливается от 14 до 45 рабочих дней, в зависимости от сложности. Точные сроки озвучит ваш менеджер при оформлении заказа.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="faq-item">
|
||||
<span class="number-circle">2</span>
|
||||
<div class="faq-item__content">
|
||||
<h4>Нужно ли вносить предоплату?</h4>
|
||||
<p>Да, для запуска заказа в производство необходима предоплата в размере 50-70% от стоимости, в зависимости от изделия. Оставшаяся сумма оплачивается при доставке и приемке мебели.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="faq-item">
|
||||
<span class="number-circle">3</span>
|
||||
<div class="faq-item__content">
|
||||
<h4>Предоставляется ли рассрочка или кредит?</h4>
|
||||
<p>Да, мы сотрудничаем с несколькими банками и предлагаем рассрочку на 6 или 12 месяцев без первоначального взноса, а также кредит на более длительный срок. Все условия уточняйте у вашего менеджера.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="faq-item">
|
||||
<span class="number-circle">4</span>
|
||||
<div class="faq-item__content">
|
||||
<h4>Что делать, если мебель пришла с дефектом?</h4>
|
||||
<p>В этом случае необходимо в течение 7 дней со дня доставки сообщить нам о проблеме, прислать фото/видео дефекта. Мы оперативно решим вопрос о бесплатной замене или ремонте изделия.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn primary-btn">Задать вопрос</button>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="footer" id="footer">
|
||||
<div class="container footer__content">
|
||||
<div class="footer__col footer--logo">
|
||||
<div class="logo">AETERNA</div>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>ПОКУПАТЕЛЮ</h5>
|
||||
<ul>
|
||||
<li><a href="javascript:void(0)" onclick="checkAuth('catalog.php')">Каталог</a></li>
|
||||
<li><a href="services.php">Услуги</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>ПОМОЩЬ</h5>
|
||||
<ul>
|
||||
<li><a href="delivery.php">Доставка и оплата</a></li>
|
||||
<li><a href="warranty.php">Гарантия и возврат</a></li>
|
||||
<li><a href="cite_mebel.php#faq">Ответы на вопросы</a></li>
|
||||
<li><a href="#footer">Контакты</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>КОНТАКТЫ</h5>
|
||||
<p>aeterna@mail.ru</p>
|
||||
<p>+7(912)999-12-23</p>
|
||||
<div class="social-icons">
|
||||
<span class="icon"><i class="fab fa-telegram"></i></span>
|
||||
<span class="icon"><i class="fab fa-instagram"></i></span>
|
||||
<span class="icon"><i class="fab fa-vk"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>ПРИНИМАЕМ К ОПЛАТЕ</h5>
|
||||
<div class="payment-icons">
|
||||
<span class="pay-icon"><i class="fab fa-cc-visa"></i></span>
|
||||
<span class="pay-icon"><i class="fab fa-cc-mastercard"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="copyright">
|
||||
<p>© 2025 AETERNA. Все права защищены.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<div class="user-status-overlay" id="userStatus" style="display: none; position: fixed; top: 20px; right: 20px; z-index: 1000; background: white; padding: 10px 15px; border-radius: 5px; box-shadow: 0 2px 10px rgba(0,0,0,0.1);">
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<i class="fas fa-user" id="statusIcon"></i>
|
||||
<div>
|
||||
<div id="statusText" style="font-weight: bold;"></div>
|
||||
<div id="userEmail" style="font-size: 12px; color: #666;"></div>
|
||||
</div>
|
||||
<button onclick="logout()" style="background: none; border: none; color: #666; cursor: pointer; margin-left: 10px;">
|
||||
<i class="fas fa-sign-out-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="quick-login-modal" id="quickLoginModal" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 2000; align-items: center; justify-content: center;">
|
||||
<div style="background: white; padding: 30px; border-radius: 10px; width: 90%; max-width: 400px; text-align: center;">
|
||||
<h3 style="margin-bottom: 20px; color: #453227;">
|
||||
<i class="fas fa-sign-in-alt"></i> Быстрый вход
|
||||
</h3>
|
||||
<div style="margin-bottom: 20px;">
|
||||
<button onclick="quickLogin('admin')" style="width: 100%; padding: 12px; background: #617365; color: white; border: none; border-radius: 4px; margin-bottom: 10px; cursor: pointer;">
|
||||
<i class="fas fa-user-shield"></i> Войти как Администратор
|
||||
</button>
|
||||
<button onclick="quickLogin('user')" style="width: 100%; padding: 12px; background: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">
|
||||
<i class="fas fa-user"></i> Войти как Пользователь
|
||||
</button>
|
||||
</div>
|
||||
<div style="font-size: 12px; color: #666; margin-top: 15px;">
|
||||
Для полного функционала перейдите на страницу входа
|
||||
</div>
|
||||
<div style="margin-top: 20px; display: flex; gap: 10px; justify-content: center;">
|
||||
<a href="вход.html" class="btn primary-btn" style="padding: 8px 15px; font-size: 14px;">
|
||||
Полный вход
|
||||
</a>
|
||||
<button onclick="hideQuickLogin()" class="btn" style="padding: 8px 15px; font-size: 14px; background: #6c757d; color: white;">
|
||||
Отмена
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
function checkAuth(redirectUrl) {
|
||||
|
||||
window.location.href = 'cite_mebel.php?action=go_to_catalog';
|
||||
return true;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
<?php if (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] === true): ?>
|
||||
if (localStorage.getItem('isLoggedIn') !== 'true') {
|
||||
localStorage.setItem('isLoggedIn', 'true');
|
||||
localStorage.setItem('user_email', '<?= addslashes($_SESSION['user_email'] ?? '') ?>');
|
||||
localStorage.setItem('isAdmin', '<?= isset($_SESSION['isAdmin']) && $_SESSION['isAdmin'] ? 'true' : 'false' ?>');
|
||||
}
|
||||
<?php endif; ?>
|
||||
|
||||
const isLoggedIn = localStorage.getItem('isLoggedIn') === 'true';
|
||||
|
||||
if (!isLoggedIn) {
|
||||
|
||||
$('a[href*="catalog"]').each(function() {
|
||||
const originalHref = $(this).attr('href');
|
||||
if (originalHref && originalHref.includes('catalog')) {
|
||||
$(this).attr('href', 'javascript:void(0)');
|
||||
$(this).addClass('link-disabled');
|
||||
$(this).click(function(e) {
|
||||
e.preventDefault();
|
||||
checkAuth(originalHref);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#searchInput').prop('disabled', true).attr('placeholder', 'Войдите для поиска');
|
||||
}
|
||||
});
|
||||
|
||||
function quickLogin(role) {
|
||||
let email, password;
|
||||
|
||||
if (role === 'admin') {
|
||||
email = 'admin@aeterna.ru';
|
||||
password = 'admin123';
|
||||
} else {
|
||||
email = 'user@test.com';
|
||||
password = 'user123';
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: 'login_handler.php',
|
||||
method: 'POST',
|
||||
data: {
|
||||
email: email,
|
||||
password: password
|
||||
},
|
||||
success: function(response) {
|
||||
try {
|
||||
const result = JSON.parse(response);
|
||||
if (result.success) {
|
||||
|
||||
localStorage.setItem('isLoggedIn', 'true');
|
||||
localStorage.setItem('user_email', email);
|
||||
localStorage.setItem('isAdmin', (role === 'admin').toString());
|
||||
|
||||
alert('Вы вошли как ' + (role === 'admin' ? 'администратор' : 'пользователь'));
|
||||
location.reload();
|
||||
}
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
$('.user-profile-toggle').click(function(e) {
|
||||
e.stopPropagation();
|
||||
$('.user-profile-menu').toggle();
|
||||
});
|
||||
|
||||
$(document).click(function() {
|
||||
$('.user-profile-menu').hide();
|
||||
});
|
||||
|
||||
$('.logout-link').click(function(e) {
|
||||
if (!confirm('Вы действительно хотите выйти?')) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
updateLoginTime();
|
||||
});
|
||||
|
||||
function updateLoginTime() {
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php if (!isset($_SESSION['isLoggedIn']) || $_SESSION['isLoggedIn'] !== true): ?>
|
||||
|
||||
<div style="position: fixed; bottom: 20px; right: 20px; z-index: 1000; background: white; padding: 10px; border-radius: 5px; box-shadow: 0 2px 10px rgba(0,0,0,0.1);">
|
||||
<h4 style="margin: 0 0 10px 0; font-size: 14px; color: #453227;">Быстрый вход:</h4>
|
||||
<button onclick="window.location.href='login.php'" style="background: #453227; color: white; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; margin: 5px; width: 100%;">
|
||||
<i class="fas fa-sign-in-alt"></i> Войти в аккаунт
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,107 +0,0 @@
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
checkAuthStatus();
|
||||
|
||||
$('#loginForm').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const email = $('#login-email').val();
|
||||
const password = $('#login-password').val();
|
||||
const remember = $('#remember').is(':checked');
|
||||
|
||||
$.ajax({
|
||||
url: 'login_handler.php',
|
||||
method: 'POST',
|
||||
data: {
|
||||
email: email,
|
||||
password: password
|
||||
},
|
||||
success: function(response) {
|
||||
try {
|
||||
const result = JSON.parse(response);
|
||||
if (result.success) {
|
||||
|
||||
if (remember) {
|
||||
localStorage.setItem('rememberedEmail', email);
|
||||
} else {
|
||||
localStorage.removeItem('rememberedEmail');
|
||||
}
|
||||
|
||||
window.location.href = result.redirect || 'catalog.php';
|
||||
} else {
|
||||
showMessage('error', result.message || 'Ошибка авторизации');
|
||||
}
|
||||
} catch(e) {
|
||||
showMessage('error', 'Ошибка обработки ответа');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
showMessage('error', 'Ошибка сервера');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function checkAuthStatus() {
|
||||
$.ajax({
|
||||
url: 'check_auth_status.php',
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
try {
|
||||
const result = JSON.parse(response);
|
||||
if (result.loggedIn) {
|
||||
updateUserProfile(result.user);
|
||||
}
|
||||
} catch(e) {
|
||||
console.error('Ошибка проверки авторизации', e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateUserProfile(user) {
|
||||
|
||||
if ($('#userEmail').length) {
|
||||
$('#userEmail').text(user.email);
|
||||
}
|
||||
if ($('#userName').length) {
|
||||
$('#userName').text(user.full_name);
|
||||
}
|
||||
}
|
||||
|
||||
function showMessage(type, text) {
|
||||
const $message = $('#' + type + 'Message');
|
||||
if ($message.length) {
|
||||
$message.text(text).fadeIn();
|
||||
setTimeout(() => $message.fadeOut(), 5000);
|
||||
} else {
|
||||
alert(text);
|
||||
}
|
||||
}
|
||||
|
||||
function checkAuth(redirectUrl) {
|
||||
$.ajax({
|
||||
url: 'check_auth_status.php',
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
try {
|
||||
const result = JSON.parse(response);
|
||||
if (result.loggedIn) {
|
||||
window.location.href = redirectUrl;
|
||||
} else {
|
||||
|
||||
showLoginModal(redirectUrl);
|
||||
}
|
||||
} catch(e) {
|
||||
showLoginModal(redirectUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function showLoginModal(redirectUrl) {
|
||||
|
||||
window.location.href = 'вход.php?redirect=' + encodeURIComponent(redirectUrl);
|
||||
}
|
||||
});
|
||||
@@ -28,5 +28,4 @@ class Database {
|
||||
public function getConnection() {
|
||||
return $this->connection;
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../config/database.php';
|
||||
?>
|
||||
<?php include 'header_common.php'; ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<base href="/cite_practica/">
|
||||
<title>AETERNA - Доставка и оплата</title>
|
||||
<link rel="stylesheet/less" type="text/css" href="style_for_cite.less">
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
<script src="check_auth.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<style>
|
||||
|
||||
.link-disabled {
|
||||
@@ -35,7 +33,6 @@ require_once __DIR__ . '/../config/database.php';
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include 'header_common.php'; ?>
|
||||
|
||||
<main class="catalog-main">
|
||||
<div class="container">
|
||||
@@ -140,8 +137,8 @@ require_once __DIR__ . '/../config/database.php';
|
||||
<div class="footer__col">
|
||||
<h5>ПОМОЩЬ</h5>
|
||||
<ul>
|
||||
<li><a href="доставка.php">Доставка и оплата</a></li>
|
||||
<li><a href="гарантия.php">Гарантия и возврат</a></li>
|
||||
<li><a href="delivery.php">Доставка и оплата</a></li>
|
||||
<li><a href="warranty.php">Гарантия и возврат</a></li>
|
||||
<li><a href="cite_mebel.php#faq">Ответы на вопросы</a></li>
|
||||
<li><a href="#footer">Контакты</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<footer class="footer" id="footer">
|
||||
<div class="container footer__content">
|
||||
<div class="footer__col footer--logo">
|
||||
<div class="logo">AETERNA</div>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>ПОКУПАТЕЛЮ</h5>
|
||||
<ul>
|
||||
<li><a href="catalog.php">Каталог</a></li>
|
||||
<li><a href="services.php">Услуги</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>ПОМОЩЬ</h5>
|
||||
<ul>
|
||||
<li><a href="delivery.php">Доставка и оплата</a></li>
|
||||
<li><a href="warranty.php">Гарантия и возврат</a></li>
|
||||
<li><a href="index.php#faq">Ответы на вопросы</a></li>
|
||||
<li><a href="#footer">Контакты</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>КОНТАКТЫ</h5>
|
||||
<p>aeterna@mail.ru</p>
|
||||
<p>+7(912)999-12-23</p>
|
||||
<div class="social-icons">
|
||||
<span class="icon"><i class="fab fa-telegram"></i></span>
|
||||
<span class="icon"><i class="fab fa-instagram"></i></span>
|
||||
<span class="icon"><i class="fab fa-vk"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>ПРИНИМАЕМ К ОПЛАТЕ</h5>
|
||||
<div class="payment-icons">
|
||||
<span class="pay-icon"><i class="fab fa-cc-visa"></i></span>
|
||||
<span class="pay-icon"><i class="fab fa-cc-mastercard"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="copyright">
|
||||
<p>© 2025 AETERNA. Все права защищены.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -128,32 +128,34 @@ $fullName = $_SESSION['full_name'] ?? $userEmail;
|
||||
</style>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
if (typeof jQuery !== 'undefined') {
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#profileToggle').click(function(e) {
|
||||
e.stopPropagation();
|
||||
$('#profileMenu').toggle();
|
||||
});
|
||||
$('#profileToggle').click(function(e) {
|
||||
e.stopPropagation();
|
||||
$('#profileMenu').toggle();
|
||||
});
|
||||
|
||||
$(document).click(function(e) {
|
||||
if (!$(e.target).closest('.user-profile-dropdown').length) {
|
||||
$('#profileMenu').hide();
|
||||
}
|
||||
});
|
||||
$(document).click(function(e) {
|
||||
if (!$(e.target).closest('.user-profile-dropdown').length) {
|
||||
$('#profileMenu').hide();
|
||||
}
|
||||
});
|
||||
|
||||
<?php if ($isLoggedIn): ?>
|
||||
$.ajax({
|
||||
url: 'api/cart.php?action=count',
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
try {
|
||||
const result = JSON.parse(response);
|
||||
if (result.success) {
|
||||
$('#cartCount').text(result.count);
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
<?php if ($isLoggedIn): ?>
|
||||
$.ajax({
|
||||
url: 'api/cart.php?action=count',
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
try {
|
||||
const result = JSON.parse(response);
|
||||
if (result.success) {
|
||||
$('#cartCount').text(result.count);
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
});
|
||||
<?php endif; ?>
|
||||
});
|
||||
<?php endif; ?>
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
1
public/img1
Symbolic link
1
public/img1
Symbolic link
@@ -0,0 +1 @@
|
||||
img
|
||||
@@ -1,49 +0,0 @@
|
||||
<footer class="footer" id="footer">
|
||||
<div class="container footer__content">
|
||||
<div class="footer__col footer--logo">
|
||||
<div class="logo">AETERNA</div>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>ПОКУПАТЕЛЮ</h5>
|
||||
<ul>
|
||||
<li><a href="catalog.php">Каталог</a></li>
|
||||
<li><a href="services.php">Услуги</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>ПОМОЩЬ</h5>
|
||||
<ul>
|
||||
<li><a href="delivery.php">Доставка и оплата</a></li>
|
||||
<li><a href="warranty.php">Гарантия и возврат</a></li>
|
||||
<li><a href="index.php#faq">Ответы на вопросы</a></li>
|
||||
<li><a href="#footer">Контакты</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>КОНТАКТЫ</h5>
|
||||
<p>aeterna@mail.ru</p>
|
||||
<p>+7(912)999-12-23</p>
|
||||
<div class="social-icons">
|
||||
<span class="icon"><i class="fab fa-telegram"></i></span>
|
||||
<span class="icon"><i class="fab fa-instagram"></i></span>
|
||||
<span class="icon"><i class="fab fa-vk"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>ПРИНИМАЕМ К ОПЛАТЕ</h5>
|
||||
<div class="payment-icons">
|
||||
<span class="pay-icon"><i class="fab fa-cc-visa"></i></span>
|
||||
<span class="pay-icon"><i class="fab fa-cc-mastercard"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="copyright">
|
||||
<p>© 2025 AETERNA. Все права защищены.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
function isLoggedIn(): bool {
|
||||
return isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] === true;
|
||||
}
|
||||
|
||||
function isAdmin(): bool {
|
||||
return isset($_SESSION['isAdmin']) && $_SESSION['isAdmin'] === true;
|
||||
}
|
||||
|
||||
function requireAuth(string $redirectUrl = 'login.php'): void {
|
||||
if (!isLoggedIn()) {
|
||||
header('Location: ' . $redirectUrl . '?error=auth_required&redirect=' . urlencode($_SERVER['REQUEST_URI']));
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
function requireAdmin(string $redirectUrl = 'login.php'): void {
|
||||
if (!isAdmin()) {
|
||||
header('Location: ' . $redirectUrl . '?error=admin_required');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
function getCurrentUser(): ?array {
|
||||
if (!isLoggedIn()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'user_id' => $_SESSION['user_id'] ?? 0,
|
||||
'email' => $_SESSION['user_email'] ?? '',
|
||||
'full_name' => $_SESSION['full_name'] ?? '',
|
||||
'is_admin' => isAdmin()
|
||||
];
|
||||
}
|
||||
|
||||
function formatPrice(float $price): string {
|
||||
return number_format($price, 0, '', ' ') . ' ₽';
|
||||
}
|
||||
|
||||
function e(string $str): string {
|
||||
return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
function generateOrderNumber(): string {
|
||||
return 'AET-' . date('Ymd') . '-' . strtoupper(substr(uniqid(), -6));
|
||||
}
|
||||
|
||||
function generateSKU(string $productName): string {
|
||||
$prefix = strtoupper(substr(preg_replace('/[^a-zA-Z0-9]/', '', transliterate($productName)), 0, 6));
|
||||
return $prefix . '-' . rand(100, 999);
|
||||
}
|
||||
|
||||
function transliterate(string $str): string {
|
||||
$converter = [
|
||||
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd',
|
||||
'е' => 'e', 'ё' => 'e', 'ж' => 'zh', 'з' => 'z', 'и' => 'i',
|
||||
'й' => 'y', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n',
|
||||
'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't',
|
||||
'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch',
|
||||
'ш' => 'sh', 'щ' => 'sch', 'ь' => '', 'ы' => 'y', 'ъ' => '',
|
||||
'э' => 'e', 'ю' => 'yu', 'я' => 'ya',
|
||||
'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D',
|
||||
'Е' => 'E', 'Ё' => 'E', 'Ж' => 'Zh', 'З' => 'Z', 'И' => 'I',
|
||||
'Й' => 'Y', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N',
|
||||
'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T',
|
||||
'У' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'Ch',
|
||||
'Ш' => 'Sh', 'Щ' => 'Sch', 'Ь' => '', 'Ы' => 'Y', 'Ъ' => '',
|
||||
'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya',
|
||||
];
|
||||
return strtr($str, $converter);
|
||||
}
|
||||
|
||||
function createSlug(string $str): string {
|
||||
$slug = transliterate($str);
|
||||
$slug = strtolower($slug);
|
||||
$slug = preg_replace('/[^a-z0-9]+/', '-', $slug);
|
||||
$slug = trim($slug, '-');
|
||||
return $slug;
|
||||
}
|
||||
|
||||
function setFlashMessage(string $type, string $message): void {
|
||||
$_SESSION['flash_message'] = [
|
||||
'type' => $type,
|
||||
'message' => $message
|
||||
];
|
||||
}
|
||||
|
||||
function getFlashMessage(): ?array {
|
||||
if (isset($_SESSION['flash_message'])) {
|
||||
$message = $_SESSION['flash_message'];
|
||||
unset($_SESSION['flash_message']);
|
||||
return $message;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
$currentPage = basename($_SERVER['PHP_SELF'], '.php');
|
||||
|
||||
$isLoggedIn = isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] === true;
|
||||
$isAdmin = isset($_SESSION['isAdmin']) && $_SESSION['isAdmin'] === true;
|
||||
$userEmail = $_SESSION['user_email'] ?? '';
|
||||
$fullName = $_SESSION['full_name'] ?? $userEmail;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AETERNA - <?= $pageTitle ?? 'Мебель и Интерьер' ?></title>
|
||||
<link rel="stylesheet/less" type="text/css" href="assets/less/style.less">
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
<style>
|
||||
|
||||
.user-profile-dropdown { position: relative; display: inline-block; }
|
||||
.user-profile-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 8px 12px; border-radius: 4px; transition: all 0.3s ease; }
|
||||
.user-profile-toggle:hover { background-color: rgba(0, 0, 0, 0.05); }
|
||||
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #617365 0%, #453227 100%); color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 16px; }
|
||||
.user-info { display: flex; flex-direction: column; }
|
||||
.user-email { font-size: 12px; color: #666; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.user-status { font-size: 10px; padding: 2px 8px; border-radius: 12px; text-transform: uppercase; font-weight: bold; text-align: center; margin-top: 2px; }
|
||||
.user-status.admin { background-color: #617365; color: white; }
|
||||
.user-status.user { background-color: #28a745; color: white; }
|
||||
.user-profile-menu { display: none; position: absolute; top: 100%; right: 0; background: white; min-width: 280px; border-radius: 8px; box-shadow: 0 5px 20px rgba(0,0,0,0.15); z-index: 1000; padding-top: 10px; border: 1px solid #e0e0e0; overflow: visible; }
|
||||
.user-profile-menu::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 10px; background: transparent; }
|
||||
.user-profile-dropdown:hover .user-profile-menu { display: block; }
|
||||
.user-profile-header { padding: 15px; background: #f8f9fa; border-bottom: 1px solid #e0e0e0; }
|
||||
.user-profile-name { font-weight: bold; margin-bottom: 5px; color: #333; display: flex; align-items: center; gap: 8px; }
|
||||
.user-profile-links { list-style: none; padding: 10px 0; margin: 0; }
|
||||
.user-profile-links a { display: flex; align-items: center; gap: 10px; padding: 10px 15px; color: #333; text-decoration: none; transition: all 0.3s ease; border-left: 3px solid transparent; }
|
||||
.user-profile-links a:hover { background-color: #f5f5f5; border-left-color: #453227; color: #453227; }
|
||||
.logout-link { color: #dc3545 !important; }
|
||||
.logout-link:hover { background-color: #ffe6e6 !important; border-left-color: #dc3545 !important; }
|
||||
.cart-icon { position: relative; margin-right: 15px; }
|
||||
.cart-count { position: absolute; top: -8px; right: -8px; background: #dc3545; color: white; border-radius: 50%; width: 18px; height: 18px; font-size: 11px; display: flex; align-items: center; justify-content: center; }
|
||||
</style>
|
||||
<?php if (isset($additionalStyles)): ?>
|
||||
<style><?= $additionalStyles ?></style>
|
||||
<?php endif; ?>
|
||||
</head>
|
||||
<body>
|
||||
<header class="header">
|
||||
<div class="header__top">
|
||||
<div class="container header__top-content">
|
||||
<div class="logo"><a href="index.php" style="text-decoration: none; color: inherit;">AETERNA</a></div>
|
||||
|
||||
<div class="search-catalog">
|
||||
<div class="catalog-dropdown">
|
||||
Все категории <span>▼</span>
|
||||
<div class="catalog-dropdown__menu">
|
||||
<ul>
|
||||
<li><a href="catalog.php">Все товары</a></li>
|
||||
<li><a href="catalog.php?category=1">Диваны</a></li>
|
||||
<li><a href="catalog.php?category=2">Кресла</a></li>
|
||||
<li><a href="catalog.php?category=3">Кровати</a></li>
|
||||
<li><a href="catalog.php?category=4">Столы</a></li>
|
||||
<li><a href="catalog.php?category=5">Стулья</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-box">
|
||||
<form method="GET" action="catalog.php" style="display: flex; width: 100%;">
|
||||
<input type="text" name="search" placeholder="Поиск товаров" style="border: none; width: 100%; padding: 10px;">
|
||||
<button type="submit" style="background: none; border: none; cursor: pointer;">
|
||||
<span class="search-icon"><i class="fas fa-search"></i></span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header__icons--top">
|
||||
<?php if ($isLoggedIn): ?>
|
||||
|
||||
<a href="checkout.php" class="icon cart-icon">
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
<span class="cart-count" id="cartCount">0</span>
|
||||
</a>
|
||||
|
||||
<div class="user-profile-dropdown">
|
||||
<div class="user-profile-toggle" id="profileToggle">
|
||||
<div class="user-avatar"><?= !empty($userEmail) ? strtoupper(substr($userEmail, 0, 1)) : 'U' ?></div>
|
||||
<div class="user-info">
|
||||
<div class="user-email"><?= htmlspecialchars($userEmail) ?></div>
|
||||
<div class="user-status <?= $isAdmin ? 'admin' : 'user' ?>"><?= $isAdmin ? 'Админ' : 'Пользователь' ?></div>
|
||||
</div>
|
||||
<i class="fas fa-chevron-down" style="font-size: 12px; color: #666;"></i>
|
||||
</div>
|
||||
|
||||
<div class="user-profile-menu" id="profileMenu">
|
||||
<div class="user-profile-header">
|
||||
<div class="user-profile-name"><i class="fas fa-user"></i> <?= htmlspecialchars($fullName) ?></div>
|
||||
</div>
|
||||
<ul class="user-profile-links">
|
||||
<li><a href="profile.php"><i class="fas fa-user-cog"></i> Мой профиль</a></li>
|
||||
<li><a href="checkout.php"><i class="fas fa-shopping-bag"></i> Мои заказы</a></li>
|
||||
<?php if ($isAdmin): ?>
|
||||
<li><a href="admin/index.php"><i class="fas fa-user-shield"></i> Админ-панель</a></li>
|
||||
<?php endif; ?>
|
||||
<li><a href="logout.php" class="logout-link"><i class="fas fa-sign-out-alt"></i> Выйти</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<a href="login.php" class="icon"><i class="far fa-user"></i></a>
|
||||
<a href="login.php" style="font-size: 12px; color: #666; margin-left: 5px;">Войти</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header__bottom">
|
||||
<div class="container header__bottom-content">
|
||||
<div class="catalog-menu">
|
||||
<a href="catalog.php" class="catalog-link <?= $currentPage === 'catalog' ? 'active' : '' ?>">
|
||||
<span class="catalog-lines">☰</span> Каталог
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<nav class="nav">
|
||||
<ul class="nav-list">
|
||||
<li><a href="index.php" class="<?= $currentPage === 'index' || $currentPage === 'cite_mebel' ? 'active' : '' ?>">Главная</a></li>
|
||||
<li><a href="services.php" class="<?= $currentPage === 'services' ? 'active' : '' ?>">Услуги</a></li>
|
||||
<li><a href="delivery.php" class="<?= $currentPage === 'delivery' ? 'active' : '' ?>">Доставка и оплата</a></li>
|
||||
<li><a href="warranty.php" class="<?= $currentPage === 'warranty' ? 'active' : '' ?>">Гарантия</a></li>
|
||||
<li><a href="#footer">Контакты</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="header-phone">+7(912)999-12-23</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#profileToggle').click(function(e) {
|
||||
e.stopPropagation();
|
||||
$('#profileMenu').toggle();
|
||||
});
|
||||
|
||||
$(document).click(function(e) {
|
||||
if (!$(e.target).closest('.user-profile-dropdown').length) {
|
||||
$('#profileMenu').hide();
|
||||
}
|
||||
});
|
||||
|
||||
<?php if ($isLoggedIn): ?>
|
||||
$.ajax({
|
||||
url: 'api/cart.php?action=count',
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
try {
|
||||
const result = JSON.parse(response);
|
||||
if (result.success) {
|
||||
$('#cartCount').text(result.count);
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
});
|
||||
<?php endif; ?>
|
||||
});
|
||||
</script>
|
||||
@@ -17,6 +17,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'go_to_catalog') {
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<base href="/cite_practica/">
|
||||
<title>AETERNA - Мебель и Интерьер</title>
|
||||
<link rel="stylesheet/less" type="text/css" href="style_for_cite.less">
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
@@ -353,10 +354,10 @@ if (isset($_GET['action']) && $_GET['action'] == 'go_to_catalog') {
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<a href="/login.php" class="icon">
|
||||
<a href="login.php" class="icon">
|
||||
<i class="far fa-user"></i>
|
||||
</a>
|
||||
<a href="/login.php" style="font-size: 12px; color: #666; margin-left: 5px;">
|
||||
<a href="login.php" style="font-size: 12px; color: #666; margin-left: 5px;">
|
||||
Войти
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
@@ -367,7 +368,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'go_to_catalog') {
|
||||
<div class="header__bottom">
|
||||
<div class="container header__bottom-content">
|
||||
<div class="catalog-menu">
|
||||
<a href="/catalog.php"
|
||||
<a href="catalog.php"
|
||||
class="catalog-link <?= (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] === true) ? '' : 'catalog-locked' ?>">
|
||||
<div class="catalog-icon">
|
||||
<span class="line"></span>
|
||||
@@ -574,7 +575,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'go_to_catalog') {
|
||||
<ul>
|
||||
<li><a href="delivery.php">Доставка и оплата</a></li>
|
||||
<li><a href="warranty.php">Гарантия и возврат</a></li>
|
||||
<li><a href="cite_mebel.html#faq">Ответы на вопросы</a></li>
|
||||
<li><a href="index.php#faq">Ответы на вопросы</a></li>
|
||||
<li><a href="#footer">Контакты</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,7 @@ session_start();
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<base href="/cite_practica/">
|
||||
<title>AETERNA - Вход</title>
|
||||
<link rel="stylesheet/less" type="text/css" href="style_for_cite.less">
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
@@ -120,7 +121,7 @@ session_start();
|
||||
<div class="header__bottom">
|
||||
<div class="container header__bottom-content">
|
||||
<div class="catalog-menu">
|
||||
<a href="/catalog.php" class="catalog-link">
|
||||
<a href="catalog.php" class="catalog-link">
|
||||
<div class="catalog-icon">
|
||||
<span class="line"></span>
|
||||
<span class="line"></span>
|
||||
@@ -204,17 +205,17 @@ session_start();
|
||||
<div class="footer__col">
|
||||
<h5>ПОКУПАТЕЛЮ</h5>
|
||||
<ul>
|
||||
<li><a href="/catalog.php">Каталог</a></li>
|
||||
<li><a href="услуги.html">Услуги</a></li>
|
||||
<li><a href="catalog.php">Каталог</a></li>
|
||||
<li><a href="services.php">Услуги</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>ПОМОЩЬ</h5>
|
||||
<ul>
|
||||
<li><a href="Доставка.html">Доставка и оплата</a></li>
|
||||
<li><a href="Гарантия.html">Гарантия и возврат</a></li>
|
||||
<li><a href="cite_mebel.html#faq">Ответы на вопросы</a></li>
|
||||
<li><a href="delivery.php">Доставка и оплата</a></li>
|
||||
<li><a href="warranty.php">Гарантия и возврат</a></li>
|
||||
<li><a href="cite_mebel.php#faq">Ответы на вопросы</a></li>
|
||||
<li><a href="#footer">Контакты</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
263
public/profile.php
Normal file
263
public/profile.php
Normal file
@@ -0,0 +1,263 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
require_once __DIR__ . '/config/database.php';
|
||||
|
||||
if (!isset($_SESSION['isLoggedIn']) || $_SESSION['isLoggedIn'] !== true) {
|
||||
header('Location: login.php?error=auth_required');
|
||||
exit();
|
||||
}
|
||||
|
||||
$user_id = $_SESSION['user_id'] ?? 0;
|
||||
$db = Database::getInstance()->getConnection();
|
||||
|
||||
// Загружаем данные пользователя
|
||||
$user = null;
|
||||
try {
|
||||
$stmt = $db->prepare("SELECT user_id, email, full_name, phone, city FROM users WHERE user_id = ?");
|
||||
$stmt->execute([$user_id]);
|
||||
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
$error = "Ошибка загрузки данных: " . $e->getMessage();
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
header('Location: login.php?error=user_not_found');
|
||||
exit();
|
||||
}
|
||||
|
||||
$update_errors = $_SESSION['update_errors'] ?? [];
|
||||
$update_success = $_SESSION['update_success'] ?? '';
|
||||
unset($_SESSION['update_errors']);
|
||||
unset($_SESSION['update_success']);
|
||||
|
||||
// Обработка обновления профиля
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$full_name = trim($_POST['fio'] ?? '');
|
||||
$city = trim($_POST['city'] ?? '');
|
||||
$phone = trim($_POST['phone'] ?? '');
|
||||
$password = $_POST['password'] ?? '';
|
||||
$confirm_password = $_POST['confirm-password'] ?? '';
|
||||
|
||||
$errors = [];
|
||||
|
||||
if (empty($full_name) || strlen($full_name) < 3) {
|
||||
$errors[] = 'ФИО должно содержать минимум 3 символа';
|
||||
}
|
||||
|
||||
if (empty($city) || strlen($city) < 2) {
|
||||
$errors[] = 'Введите корректное название города';
|
||||
}
|
||||
|
||||
if (empty($phone) || !preg_match('/^(\+7|8)[\s-]?\(?\d{3}\)?[\s-]?\d{3}[\s-]?\d{2}[\s-]?\d{2}$/', $phone)) {
|
||||
$errors[] = 'Введите корректный номер телефона';
|
||||
}
|
||||
|
||||
if (!empty($password)) {
|
||||
if (strlen($password) < 6) {
|
||||
$errors[] = 'Пароль должен содержать минимум 6 символов';
|
||||
}
|
||||
if ($password !== $confirm_password) {
|
||||
$errors[] = 'Пароли не совпадают';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
if (!empty($password)) {
|
||||
$password_hash = password_hash($password, PASSWORD_DEFAULT);
|
||||
$stmt = $db->prepare("
|
||||
UPDATE users
|
||||
SET full_name = ?, phone = ?, city = ?, password_hash = ?, updated_at = CURRENT_TIMESTAMP
|
||||
WHERE user_id = ?
|
||||
");
|
||||
$stmt->execute([$full_name, $phone, $city, $password_hash, $user_id]);
|
||||
} else {
|
||||
$stmt = $db->prepare("
|
||||
UPDATE users
|
||||
SET full_name = ?, phone = ?, city = ?, updated_at = CURRENT_TIMESTAMP
|
||||
WHERE user_id = ?
|
||||
");
|
||||
$stmt->execute([$full_name, $phone, $city, $user_id]);
|
||||
}
|
||||
|
||||
$_SESSION['full_name'] = $full_name;
|
||||
$_SESSION['user_phone'] = $phone;
|
||||
$_SESSION['user_city'] = $city;
|
||||
|
||||
$_SESSION['update_success'] = 'Профиль успешно обновлен!';
|
||||
header('Location: profile.php');
|
||||
exit();
|
||||
} catch (PDOException $e) {
|
||||
$errors[] = 'Ошибка обновления: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
$_SESSION['update_errors'] = $errors;
|
||||
header('Location: profile.php');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="/cite_practica/">
|
||||
<title>AETERNA - Мой профиль</title>
|
||||
<link rel="stylesheet/less" type="text/css" href="style_for_cite.less">
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
<style>
|
||||
body {
|
||||
padding-bottom: 120px;
|
||||
}
|
||||
.profile-page-main {
|
||||
min-height: calc(100vh - 0px);
|
||||
}
|
||||
.update-errors {
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
margin: 20px auto;
|
||||
max-width: 800px;
|
||||
border: 1px solid #f5c6cb;
|
||||
}
|
||||
.update-success {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
margin: 20px auto;
|
||||
max-width: 800px;
|
||||
border: 1px solid #c3e6cb;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<?php include 'header_common.php'; ?>
|
||||
|
||||
<main class="profile-page-main">
|
||||
<?php if (!empty($update_errors)): ?>
|
||||
<div class="update-errors">
|
||||
<h4><i class="fas fa-exclamation-circle"></i> Ошибки:</h4>
|
||||
<ul>
|
||||
<?php foreach ($update_errors as $error): ?>
|
||||
<li><?= htmlspecialchars($error) ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($update_success)): ?>
|
||||
<div class="update-success">
|
||||
<i class="fas fa-check-circle"></i> <?= htmlspecialchars($update_success) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="profile-container">
|
||||
<div class="profile-left-col">
|
||||
<div class="logo" style="color: white;">AETERNA</div>
|
||||
<div style="margin-top: 30px; color: rgba(255,255,255,0.8);">
|
||||
<h3 style="margin-bottom: 15px; font-size: 18px;">Мой профиль</h3>
|
||||
<p style="font-size: 14px; line-height: 1.5;">
|
||||
Управляйте своими данными и настройками аккаунта
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="profile-right-col">
|
||||
<div class="profile-form-block">
|
||||
<h2>РЕДАКТИРОВАНИЕ ПРОФИЛЯ</h2>
|
||||
<form class="profile-form" method="POST" id="profileForm">
|
||||
<div class="input-group">
|
||||
<label for="email">E-mail</label>
|
||||
<input type="email" id="email" value="<?= htmlspecialchars($user['email']) ?>" disabled>
|
||||
<small style="color: #666; font-size: 12px;">E-mail нельзя изменить</small>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="fio">ФИО *</label>
|
||||
<input type="text" id="fio" name="fio" placeholder="Введите ваше ФИО"
|
||||
value="<?= htmlspecialchars($user['full_name'] ?? '') ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="city">Город *</label>
|
||||
<input type="text" id="city" name="city" placeholder="Укажите ваш город"
|
||||
value="<?= htmlspecialchars($user['city'] ?? '') ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="phone">Телефон *</label>
|
||||
<input type="tel" id="phone" name="phone" placeholder="+7(912)999-12-23"
|
||||
value="<?= htmlspecialchars($user['phone'] ?? '') ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="password">Новый пароль (оставьте пустым, если не хотите менять)</label>
|
||||
<input type="password" id="password" name="password" placeholder="Придумайте новый пароль">
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="confirm-password">Подтвердите новый пароль</label>
|
||||
<input type="password" id="confirm-password" name="confirm-password" placeholder="Повторите пароль">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn primary-btn save-btn">
|
||||
Сохранить изменения
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#phone').on('input', function() {
|
||||
let value = $(this).val().replace(/\D/g, '');
|
||||
if (value.length > 0) {
|
||||
if (!value.startsWith('7') && !value.startsWith('8')) {
|
||||
value = '7' + value;
|
||||
}
|
||||
if (value.startsWith('8')) {
|
||||
value = '7' + value.substring(1);
|
||||
}
|
||||
let formatted = '+7';
|
||||
if (value.length > 1) formatted += ' (' + value.substring(1, 4);
|
||||
if (value.length > 4) formatted += ') ' + value.substring(4, 7);
|
||||
if (value.length > 7) formatted += '-' + value.substring(7, 9);
|
||||
if (value.length > 9) formatted += '-' + value.substring(9, 11);
|
||||
$(this).val(formatted);
|
||||
}
|
||||
});
|
||||
|
||||
$('#profileForm').on('submit', function(e) {
|
||||
const password = $('#password').val();
|
||||
const confirmPassword = $('#confirm-password').val();
|
||||
|
||||
if (password && password !== confirmPassword) {
|
||||
e.preventDefault();
|
||||
alert('Пароли не совпадают');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (password && password.length < 6) {
|
||||
e.preventDefault();
|
||||
alert('Пароль должен содержать минимум 6 символов');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -29,7 +29,7 @@ if (isset($_GET['quick_login'])) {
|
||||
}
|
||||
|
||||
session_start();
|
||||
require_once __DIR__ . '/../config/database.php';
|
||||
require_once __DIR__ . '/config/database.php';
|
||||
|
||||
if (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] === true) {
|
||||
header('Location: catalog.php');
|
||||
@@ -102,6 +102,7 @@ if (isset($_GET['quick_register'])) {
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="/cite_practica/">
|
||||
<title>AETERNA - Регистрация</title>
|
||||
<link rel="stylesheet/less" type="text/css" href="style_for_cite.less">
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
@@ -212,10 +213,10 @@ if (isset($_GET['quick_register'])) {
|
||||
<a href="javascript:void(0)" onclick="checkAuth('checkout.php')" class="icon">
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
</a>
|
||||
<a href="/login.php" class="icon">
|
||||
<a href="login.php" class="icon">
|
||||
<i class="far fa-user"></i>
|
||||
</a>
|
||||
<a href="/login.php" style="font-size: 12px; color: #666; margin-left: 5px;">
|
||||
<a href="login.php" style="font-size: 12px; color: #666; margin-left: 5px;">
|
||||
Войти
|
||||
</a>
|
||||
</div>
|
||||
@@ -348,7 +349,7 @@ if (isset($_GET['quick_register'])) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="/login.php" class="password-link" style="display: block; margin: 15px 0; text-align: center; color: #453227;">
|
||||
<a href="login.php" class="password-link" style="display: block; margin: 15px 0; text-align: center; color: #453227;">
|
||||
Уже есть аккаунт? Войти
|
||||
</a>
|
||||
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../config/database.php';
|
||||
?>
|
||||
<?php include 'header_common.php'; ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<base href="/cite_practica/">
|
||||
<title>AETERNA - Услуги</title>
|
||||
<link rel="stylesheet/less" type="text/css" href="style_for_cite.less">
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
<script src="check_auth.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<style>
|
||||
|
||||
.link-disabled {
|
||||
@@ -35,7 +33,6 @@ require_once __DIR__ . '/../config/database.php';
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include 'header_common.php'; ?>
|
||||
|
||||
<main>
|
||||
<section class="services-section">
|
||||
@@ -69,17 +66,17 @@ require_once __DIR__ . '/../config/database.php';
|
||||
<div class="footer__col">
|
||||
<h5>ПОКУПАТЕЛЮ</h5>
|
||||
<ul>
|
||||
<li><a href="/catalog.php">Каталог</a></li>
|
||||
<li><a href="услуги.html">Услуги</a></li>
|
||||
<li><a href="catalog.php">Каталог</a></li>
|
||||
<li><a href="services.php">Услуги</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="footer__col">
|
||||
<h5>ПОМОЩЬ</h5>
|
||||
<ul>
|
||||
<li><a href="Доставка.html">Доставка и оплата</a></li>
|
||||
<li><a href="Гарантия.html">Гарантия и возврат</a></li>
|
||||
<li><a href="cite_mebel.html#faq">Ответы на вопросы</a></li>
|
||||
<li><a href="delivery.php">Доставка и оплата</a></li>
|
||||
<li><a href="warranty.php">Гарантия и возврат</a></li>
|
||||
<li><a href="cite_mebel.php#faq">Ответы на вопросы</a></li>
|
||||
<li><a href="#footer">Контакты</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../config/database.php';
|
||||
?>
|
||||
<?php include 'header_common.php'; ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<base href="/cite_practica/">
|
||||
<title>AETERNA - Гарантия</title>
|
||||
<link rel="stylesheet/less" type="text/css" href="style_for_cite.less">
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
<script src="check_auth.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<style>
|
||||
|
||||
.link-disabled {
|
||||
@@ -35,7 +33,6 @@ require_once __DIR__ . '/../config/database.php';
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include 'header_common.php'; ?>
|
||||
|
||||
<main class="catalog-main">
|
||||
<div class="container">
|
||||
|
||||
Reference in New Issue
Block a user