2022-12-11 13:55:49 +05:00
|
|
|
<?php
|
|
|
|
ini_set('display_errors', 0 );
|
2023-01-14 21:17:46 +05:00
|
|
|
function ekr ($text) { // ФУНКЦИЯ очистки кода
|
|
|
|
|
|
|
|
$old1 = array(" ");#Ищем вредное ">",, "<"
|
|
|
|
|
|
|
|
$new1 = array("%");#Меняем на полезное">", , "<"
|
|
|
|
|
|
|
|
$text = str_replace($old1, $new1, $text);#Собсно сама замена =)
|
|
|
|
|
|
|
|
return $text; }
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-01-02 21:33:36 +05:00
|
|
|
|
|
|
|
$massiv=\DB::getAll(
|
2023-05-03 14:51:58 +05:00
|
|
|
"SELECT * FROM `tovar` WHERE (`id`=? OR `title` LIKE '%" . ekr( $_POST['txt'] ) . "%' OR `artikul`=?) AND `status`=1",
|
|
|
|
array($_POST['txt'], $_POST['txt']) );
|
2023-01-02 21:33:36 +05:00
|
|
|
|
|
|
|
|
|
|
|
//Получаем фото
|
|
|
|
for ( $i=0; $i <count( $massiv ); $i++ ) {
|
|
|
|
$massiv[$i]['img'] = \DB::getValue( "SELECT `filename` FROM `tovar_img` WHERE `tovar_id`=? LIMIT 1", $massiv[$i]['id'] );
|
|
|
|
$massiv[$i]['cena'] = \DB::getValue( "SELECT `cena` FROM `tovar_price_history` WHERE `tovar_id`=? ORDER BY `t` DESC LIMIT 1", $massiv[$i]['id'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
2022-12-11 13:55:49 +05:00
|
|
|
$sql='SELECT `id`, `txt`, `tip` FROM `pages` WHERE `txt` LIKE "%' . $txt . '%" OR `artikul` LIKE "%' . $txt . '%" ORDER BY `tip`';
|
|
|
|
$massiv=$db->free_sql($sql);
|
|
|
|
function getTip($tip){
|
|
|
|
$arr['page']='Страница';
|
|
|
|
$arr['category']='Раздел';
|
|
|
|
$arr['tovar']='Товар';
|
|
|
|
$arr['tovar_cat']='Категория товара';
|
|
|
|
return $arr[$tip];
|
|
|
|
}
|
|
|
|
$count=count($massiv);
|
|
|
|
for ($i=0; $i<$count; $i++){
|
|
|
|
unset($a);
|
|
|
|
$a['page_id']=$massiv[$i]['id'];
|
|
|
|
$massiv[$i]['img']=$db->get_val('img', $a, 'fileName');
|
|
|
|
$massiv[$i]['tip']=getTip($massiv[$i]['tip']);
|
2023-01-02 21:33:36 +05:00
|
|
|
}*/
|
|
|
|
|
|
|
|
$smarty->assign('title', "Поиск по сайту - " . $_POST['txt']);
|
2022-12-11 13:55:49 +05:00
|
|
|
$smarty->assign('list', $massiv);//получаем дочерние категории
|
|
|
|
?>
|