Файл: upload/core/functions/catalog.php
Строк: 57
<?php
function deletesection($id)
{
$workrz = FetchAssoc(dbquery("SELECT * FROM section WHERE id = ?", [$id]));
if (!empty($workrz['id'])) {
deleteWorks($workrz['id']);
if (!empty($workrz['k_image']) && $workrz['k_image'] != 'non-image.png') {
$path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/sections/' . $workrz['k_image'];
if (is_file($path)) {
unlink($path);
}
}
dbquery("DELETE FROM section WHERE id = ?", [$id]);
}
}
function deletesubcategory($id)
{
$subcategory = FetchAssoc(dbquery("SELECT * FROM `subcategory` WHERE id = ?", [$id]));
if (empty($subcategory['id'])) {
return;
}
$sections = dbquery("SELECT id FROM `section` WHERE `subcategory` = ?", [$subcategory['id']]);
while ($rz = FetchAssoc($sections)) {
deletesection($rz['id'] ?? '');
}
dbquery("DELETE FROM `subcategory` WHERE id = ?", [$id]);
}
function deleteCategory($id)
{
$category = FetchAssoc(dbquery("SELECT * FROM `category` WHERE `id` = ?", [$id]));
if (empty($category['id'])) {
return;
}
$podcats = dbquery("SELECT `id` FROM `subcategory` WHERE `category` = ?", [$category['id']]);
while ($pc = FetchAssoc($podcats)) {
deletesubcategory($pc['id'] ?? '');
}
if (!empty($category['k_image']) && $category['k_image'] != 'non-image.png') {
$path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/categories/' . $category['k_image'];
if (is_file($path)) {
unlink($path);
}
}
dbquery("DELETE FROM `category` WHERE `id` = ?", [$id]);
}
function GetCategoryImage($image)
{
global $theme;
$theme_url = homeLink() . '/core/templates/';
$default_image = $theme_url . $theme . '/images/catalog/category/non-image.png';
if (!$image || $image === 'non-image.png') {
return $default_image;
}
$path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/categories/' . $image;
if (file_exists($path)) {
return homeLink() . '/uploads/categories/' . $image;
}
return $default_image;
}
function GetSectionImage($image)
{
global $theme;
$theme_url = homeLink() . '/core/templates/';
$default_image = $theme_url . $theme . '/images/catalog/section/non-image.png';
if (!$image || $image === 'non-image.png') {
return $default_image;
}
$path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/sections/' . $image;
if (file_exists($path)) {
return homeLink() . '/uploads/sections/' . $image;
}
return $default_image;
}
?>