2025-06-16 18:28:08 +05:00

91 lines
3.6 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
switch (@$_POST['act']) {
case 'add_comment':
print_r($_POST);
if (!$_SESSION['user_id'] || !$_POST['txt'])
die();
$_POST['t'] = time();
$_POST['user_id'] = $_SESSION['user_id'];
unset($_POST['act']);
$db->add('pages_comments', $_POST);
break;
case 'like':
unset($a);
unset($b);
$a['id'] = $_POST['id'];
$b['likes'] = $db->get_val('pages', $a, 'likes') + 1;
setcookie("page_like", $a['id'], time() + 31536000, '/', $_SERVER['SERVER_NAME']);
$db->update('pages', $a['id'], $b);
echo 1;
break;
case 'contentDown':
$limit = $_POST['limit'];
$page = intval(@$_POST['page']);
$page = (empty($page)) ? 1 : $page;
$start = ($page != 1) ? $page * $limit - $limit : 0;
if (class_exists('DBmysql')) {
$list = \DBmysql::getAll("SELECT `id`, `title`, `cena`, `artikul`, `code` FROM `tovar` WHERE
`status`=1 AND (`title` LIKE '%" . $_POST['txt'] . "%' OR `artikul` LIKE '%" . $_POST['txt'] . "%'
OR `code` ='" . $_POST['txt'] . "' OR `json` LIKE '%" . $_POST['txt'] . "%' ) AND `site`=? LIMIT $start, $limit", $_SERVER['SERVER_NAME']);
$count = count($list);
for ($i = 0; $i < $count; $i++) {
//Костыль
//$filename = \DBmysql::getValue("SELECT `filename` FROM `img` WHERE `content_id`=? AND `site`=? AND `content_type`=? LIMIT 1", [$list[$i]['id'], $_SERVER['SERVER_NAME'],'tovar']);
if (class_exists('DBmysql')) {
$filename=\DBmysql::getValue("SELECT `filename` FROM `img` WHERE `site`=? AND `content_id`=? AND `content_type`=? LIMIT 1", [$_SERVER['SERVER_NAME'], $list[$i]['id'], 'tovar']);
}else{
$filename=\DB::getValue("SELECT `filename` FROM `img` WHERE `site`=? AND `content_id`=? AND `content_type`=? LIMIT 1", [$_SERVER['SERVER_NAME'], $list[$i]['id'], 'tovar']);
}
if (!$filename) {
$img = 'https://static.yurecnt.ru/img/nofoto/no_skin.png';
} else {
$f = 'cache/img/' . $filename . '-' . IMG_PRV_W . '-' . IMG_PRV_H . '.webp';
if (file_exists($f))
$img = '/' . $f;
else
$img = '/img/' . $filename . '-' . IMG_PRV_W . '-' . IMG_PRV_H;
}
$a = ($list[$i]['artikul']) ? $list[$i]['artikul'] : $list[$i]['code'];
$res .= '
<div style="width:300px; padding-bottom: 10px;">
<div class="card" style="width: 280px;">
<div style="height: 280px;">
<a href="/tovar_show/' . $list[$i]['id'] . '"><img
src="' . $img . '" class="card-img-top" alt="..." style="width: 280px"></a>
</div>
<div class="card-body" style="text-align: center;">
<div style="height: 100px; margin-bottom: 10px;">
<h5 class="card-title" style="font-size: 12pt; font-weight: 100;"><a href="/tovar_show/' . $list[$i]['id'] . '">' . mb_substr($list[$i]['title'], 0, 50) . '</a>
</h5>
</div>
<small
style="background-color: lightblue; padding: 5px; width: 100%; margin-bottom: 10px; margin-top: 10px;">Актикул: ' .
$a . '</small>
<!--p class="card-text">Небольшой пример текста, который должен основываться на названии карточки и составлять основную часть содержимого карты.</p-->
<a href="/tovar_show/' . $list[$i]['id'] . '" class="btn btn-primary" style="width: 100%;"><i
class="fa-solid fa-cart-shopping"></i>' . $list[$i]['cena'] . ' р.</a>
</div>
</div>
</div>';
}
}
echo $res;
break;
default:
}
?>