2022-12-11 13:55:49 +05:00
|
|
|
<?php
|
2023-07-12 20:02:20 +05:00
|
|
|
ini_set('display_errors', 0);
|
|
|
|
function ekr($text)
|
|
|
|
{ // ФУНКЦИЯ очистки кода
|
|
|
|
$old1 = array(" "); #Ищем вредное ">",, "<"
|
|
|
|
$new1 = array("%"); #Меняем на полезное">", , "<"
|
|
|
|
$text = str_replace($old1, $new1, $text); #Собсно сама замена =)
|
|
|
|
return $text;
|
2023-01-02 21:33:36 +05:00
|
|
|
}
|
2023-07-12 20:02:20 +05:00
|
|
|
$massiv = \DB::getAll(
|
|
|
|
"SELECT tovar.id, tovar.title, tovar.cena, tovar_img.filename AS img
|
|
|
|
FROM `tovar`
|
|
|
|
JOIN `tovar_img`
|
|
|
|
ON tovar_img.tovar_id=tovar.id
|
|
|
|
WHERE
|
|
|
|
tovar.title LIKE '%" . ekr($_POST['txt']) . "%'
|
|
|
|
OR tovar.artikul LIKE '%" . $_POST['txt'] . "%'
|
|
|
|
OR tovar.id IN (SELECT `tovar_id` FROM `tovar_barcode` WHERE `barcode`='" . $_POST['txt'] . "')",
|
|
|
|
$_POST['txt']
|
|
|
|
);
|
2023-01-02 21:33:36 +05:00
|
|
|
$smarty->assign('title', "Поиск по сайту - " . $_POST['txt']);
|
2023-07-12 20:02:20 +05:00
|
|
|
$massiv2 = \core::array_unique_key($massiv, 'id');
|
|
|
|
$smarty->assign('list', $massiv2); //уникализируем массив и выводим в шаблон
|
|
|
|
$count = count($massiv2);
|
|
|
|
$c = \DB::getValue("SELECT `c` FROM `find_history` WHERE `txt`=? LIMIT 1", $_POST['txt']);
|
|
|
|
if ($c) {
|
|
|
|
$c++;
|
|
|
|
\DB::set("UPDATE `find_history` SET `c`=?, `t`=?, `countq`=? WHERE `txt`=?", array(
|
|
|
|
$c,
|
|
|
|
time(),
|
|
|
|
$count, $_POST['txt']
|
|
|
|
)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$c = 1;
|
|
|
|
\DB::add(
|
|
|
|
"INSERT INTO `find_history` (`c`, `t`, `countq`, `txt`) VALUES (?, ?, ?, ?)",
|
|
|
|
array(
|
|
|
|
$c,
|
|
|
|
time(),
|
|
|
|
$count, $_POST['txt']
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2022-12-11 13:55:49 +05:00
|
|
|
?>
|