<?php
require_once('../wu_init.php');
require('../wu-functions/wu_presearch.php');
require('../wu-functions/wu_functions.php');
function cat($id) {
switch ($id) {
case '1': $cat = 'Скрипты порталов'; $caturl = 'port_script'; break;
case '2': $cat = 'Скрипты казино'; $caturl = 'kazino_script'; break;
case '3': $cat = 'Доски объявлений'; $caturl = 'doska_script'; break;
case '4': $cat = 'Интернет магазины'; $caturl = 'shop_script'; break;
case '5': $cat = 'Скрипты буксов,CAP'; $caturl = 'cap_script'; break;
case '6': $cat = 'Скрипты хайпов'; $caturl = 'hayp_script'; break;
case '7': $cat = 'Экономические игры'; $caturl = 'games_script'; break;
case '8': $cat = 'Модули для CMS'; $caturl = 'moduls_cms'; break;
case '9': $cat = 'Остальное'; $caturl = 'other'; break;
default: $cat = 'Ошибка категории'; $caturl = '';
}
return Array($cat, $caturl);
}
$loading_count_posts = 10;
$path = "/wu-engine/wu-actions/eshop_search.php";
$count = intval($_GET["count"]);
if(isset($_POST['text'])){
$text = mysqli_real_escape_string($connect_db, $_POST['text']);
if (!USER_LOGGED) { $nlog = 330; } else { $nlog = $u_id; }
if ($count < 10) {
$stemming= new Stemming();
$stem_str=$stemming->stem_string($text);
$search_req = " AND ( ";
$search_array = explode(" ", $stem_str);
$search_str=preg_replace("/[^а-яА-Яa-zA-z0-9\-]/ui","%",$stem_str);
$search_columns=array(
'ti'=>'20',
'ts'=>'10',
'tf'=>'15'
);
$select =", ( 0";
$search_req_arr=array();
foreach($search_columns as $col=>$coeff) {
$select.= " + IF ($col LIKE '".$search_str."', $coeff*3, 0)";
$search_req_arr[]= " $col LIKE '%".$search_str."%'";
$word_coeff=round(($coeff/count($search_array)),2);
foreach($search_array as $word) {
$select .= "+ IF ($col LIKE '%".$word."%', ".$word_coeff.", 0)";
$search_req_arr[] = "$col LIKE '%".$word."%'";
}
}
$select.=") AS `relevant`";
$search_req .=implode(" OR ",$search_req_arr);
$search_req .= ")";
if (isset($_POST['cat']) && !empty($_POST['cat'])) {
$allcat = ' AND ( ';
foreach($_POST['cat'] AS $key => $value)
{
if ($value > 0) { $value = intval($value); $allcat .= "cat = $value OR "; $toget .= "&cat[]=$value"; }
}
$allcat = substr($allcat, 0, -3);
$allcat .= ')';
}
$result = mysqli_query($connect_db, "SELECT ".DB_PREFIX."_es.id,inf,ty,cat,co,ti,ts,col,dt,v,vo,va,log,rat,img $select FROM ".DB_PREFIX."_es INNER JOIN ".DB_PREFIX."_es_i ON ".DB_PREFIX."_es.id = ".DB_PREFIX."_es_i.m INNER JOIN ".DB_PREFIX."_users ON ".DB_PREFIX."_es.usr = ".DB_PREFIX."_users.uid WHERE st = '1' $search_req$allcat GROUP BY ".DB_PREFIX."_es.id ORDER BY relevant DESC LIMIT $count, 10");
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result)) {
list($cat, $caturl) = cat($row['cat']);
if (USER_LOGGED) {
$fav = mysqli_num_rows(mysqli_query($connect_db, "SELECT id FROM ".DB_PREFIX."_es_f WHERE usr='$u_id' AND f='$row[id]' LIMIT 1"));
}
?>
<div class="panel panel-<?php if ($row['col'] == 1) { echo 'info'; } else { echo 'default'; } ?>">
<div class="panel-heading">
<h6 class="panel-title<?php if ($row['col'] == 1) { echo ' esinf'; } ?>"><a href="/eshop_show/<?php echo $row['id']; ?>"><?php echo $row['ti']; ?></a></h6>
<div class="panel-icons-group<?php if ($row['col'] == 1) { echo ' esinf'; } ?>">
<a href="javascript://" class="btn btn-link ptext tip" data-placement="bottom" data-original-title="Количество просмотров товара">Просмотров: <?php echo $row["v"]; ?></a>
<a href="javascript://" class="btn btn-link ptext tip" data-placement="bottom" data-original-title="Количество комментариев к товару">Комментариев: <?php $sumc = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `cnt` FROM ".DB_PREFIX."_es_c WHERE m='$row[id];'")); echo $sumc['cnt']; ?></a>
<a href="javascript://" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Рейтинг товара: <?php if ($row['vo'] > 0) { $rt = $row['va']/$row['vo']; $rt = number_format($rt,2,'.',''); } else { $rt = "Голосов нет"; } echo $rt; ?>"><i class="icon-star<?php if ($rt >=2.5 && $rt < 4) { echo '2'; } if ($rt >=4) { echo '3'; } ?>"></i></a>
<a href="javascript://" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Размещено <?php echo wudate($row['dt']); ?>"><i class="icon-clock3"></i></a>
<a href="/user/<?php echo $row['log']; ?>" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Все товары пользователя <?php echo $row['log']; ?>"><i class="icon-user2"></i></a>
<a href="javascript://" onclick="fav('<?php echo $row['id']; ?>');" id="fav_<?php echo $row['id']; ?>"<?php if ($fav > 0) { echo ' style="display: none"'; } ?> class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Добавить в избранное" data-loading-text="<i class='icon-spinner7 spin'></i>"><i class="icon-heart2"></i></a>
<a href="javascript://" onclick="favb('<?php echo $row['id']; ?>');" id="favb_<?php echo $row['id']; ?>"<?php if (!USER_LOGGED || $fav == 0) { echo ' style="display: none"'; } ?> class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Удалить из избранного" data-loading-text="<i class='icon-spinner7 spin'></i>"><i class="icon-heart"></i></a>
</div>
</div>
<div class="panel-body">
<div class="media">
<div class="lightgallerys pull-left marnone">
<a href="/eshop/images/<?php echo $row['img']; ?>" data-sub-html="<?php echo $row['ti']; ?>"><img class="imgeshop" src="/eshop/images/<?php echo $row['img']; ?>" border="0" alt="<?php echo $row['ti']; ?>" title="<?php echo $row['ti']; ?>" /></a>
</div>
<div class="clearh"></div>
<div class="media-body cpn marnone">
<div class="col-lg-9 col-md-6 col-sm-6 emarg">
<?php echo nl2br(htmlspecialchars($row['ts'])); ?>
</div>
<div class="col-lg-3 col-md-6 col-sm-6 well einf">
<ul>
<li>Стоимость: <font class="flright fbold"><?php echo $row['co']; ?> руб.</font></li>
<li>Категория: <font class="flright"><a href="/category/<?php echo $caturl; ?>"><?php echo $cat; ?></a></font></li>
<li>Тип товара: <font class="flright"><?php if ($row['ty'] == 0) { echo 'Файл'; } if ($row['ty'] == 1) { echo 'Текст'; } ?></font></li>
<li>Количество: <font class="flright"><?php if ($row['inf'] == 0) { echo 'Бесконечно'; } if ($row['inf'] == 1) { $units = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `c` FROM d_es_u WHERE m = '$row[id]' AND st = '0'")); if ($units['c'] > 0) { echo $units['c'].' шт.'; } else { echo 'Всё продано'; } } ?></font></li>
<li>Рейтинг продавца: <font class="flright"><?php echo $row['rat']; ?></font></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<?php } } else { echo '<div class="alert alert-info fade in"><i class="icon-info"></i> Ничего не найдено</div>'; }
$posts = "$path?count=10&token=$token&text=".urlencode($text)."$toget";
?>
<a href="<?php echo $posts; ?>" class="ajaxnext"></a>
<script type='text/javascript'>
$('.lightgallerys').lightGallery();
$('.tip').tooltip();
</script>
<?php
}
}
if(isset($_GET['text']) && isset($_GET['count'])){
$text = mysqli_real_escape_string($connect_db, $_GET['text']);
if ($count >= 10) {
$stemming= new Stemming();
$stem_str=$stemming->stem_string($text);
$search_req = " AND ( ";
$search_array = explode(" ", $stem_str);
$search_str=preg_replace("/[^а-яА-Яa-zA-z0-9\-]/ui","%",$stem_str);
$search_columns=array(
'ti'=>'20',
'ts'=>'10',
'tf'=>'15'
);
$select =", ( 0";
$search_req_arr=array();
foreach($search_columns as $col=>$coeff) {
$select.= " + IF ($col LIKE '".$search_str."', $coeff*3, 0)";
$search_req_arr[]= " $col LIKE '%".$search_str."%'";
$word_coeff=round(($coeff/count($search_array)),2);
foreach($search_array as $word) {
$select .= "+ IF ($col LIKE '%".$word."%', ".$word_coeff.", 0)";
$search_req_arr[] = "$col LIKE '%".$word."%'";
}
}
$select.=") AS `relevant`";
$search_req .=implode(" OR ",$search_req_arr);
$search_req .= ")";
if (isset($_GET['cat']) && !empty($_GET['cat'])) {
$allcat = ' AND ( ';
foreach($_GET['cat'] AS $key => $value)
{
if ($value > 0) { $allcat .= "cat = $value OR "; $toget .= "&cat[]=$value"; }
}
$allcat = substr($allcat, 0, -3);
$allcat .= ')';
}
$result = mysqli_query($connect_db, "SELECT ".DB_PREFIX."_es.id,inf,ty,cat,co,ti,ts,col,dt,v,vo,va,log,rat,img $select FROM ".DB_PREFIX."_es INNER JOIN ".DB_PREFIX."_es_i ON ".DB_PREFIX."_es.id =  ".DB_PREFIX."_es_i.m INNER JOIN ".DB_PREFIX."_users ON ".DB_PREFIX."_es.usr = ".DB_PREFIX."_users.uid WHERE st = '1' $search_req$allcat GROUP BY d_es.id ORDER BY relevant DESC LIMIT $count, 10");
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result)) {
list($cat, $caturl) = cat($row['cat']);
if (USER_LOGGED) {
$fav = mysqli_num_rows(mysqli_query($connect_db, "SELECT id FROM ".DB_PREFIX."_es_f WHERE usr='$u_id' AND f='$row[id]' LIMIT 1"));
}
?>
<div class="panel panel-<?php if ($row['col'] == 1) { echo 'info'; } else { echo 'default'; } ?>">
<div class="panel-heading">
<h6 class="panel-title<?php if ($row['col'] == 1) { echo ' esinf'; } ?>"><a href="/eshop_show/<?php echo $row['id']; ?>"><?php echo $row['ti']; ?></a></h6>
<div class="panel-icons-group<?php if ($row['col'] == 1) { echo ' esinf'; } ?>">
<a href="javascript://" class="btn btn-link ptext tip" data-placement="bottom" data-original-title="Количество просмотров товара">Просмотров: <?php echo $row["v"]; ?></a>
<a href="javascript://" class="btn btn-link ptext tip" data-placement="bottom" data-original-title="Количество комментариев к товару">Комментариев: <?php $sumc = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `cnt` FROM ".DB_PREFIX."_es_c WHERE m='$row[id];'")); echo $sumc['cnt']; ?></a>
<a href="javascript://" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Рейтинг товара: <?php if ($row['vo'] > 0) { $rt = $row['va']/$row['vo']; $rt = number_format($rt,2,'.',''); } else { $rt = "Голосов нет"; } echo $rt; ?>"><i class="icon-star<?php if ($rt >=2.5 && $rt < 4) { echo '2'; } if ($rt >=4) { echo '3'; } ?>"></i></a>
<a href="javascript://" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Размещено <?php echo wudate($row['dt']); ?>"><i class="icon-clock3"></i></a>
<a href="/user/<?php echo $row['log']; ?>" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Все товары пользователя <?php echo $row['log']; ?>"><i class="icon-user2"></i></a>
<a href="javascript://" onclick="fav('<?php echo $row['id']; ?>');" id="fav_<?php echo $row['id']; ?>"<?php if ($fav > 0) { echo ' style="display: none"'; } ?> class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Добавить в избранное" data-loading-text="<i class='icon-spinner7 spin'></i>"><i class="icon-heart2"></i></a>
<a href="javascript://" onclick="favb('<?php echo $row['id']; ?>');" id="favb_<?php echo $row['id']; ?>"<?php if (!USER_LOGGED || $fav == 0) { echo ' style="display: none"'; } ?> class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Удалить из избранного" data-loading-text="<i class='icon-spinner7 spin'></i>"><i class="icon-heart"></i></a>
</div>
</div>
<div class="panel-body">
<div class="media">
<div class="lightgallerys pull-left marnone">
<a href="/eshop/images/<?php echo $row['img']; ?>" data-sub-html="<?php echo $row['ti']; ?>"><img class="imgeshop" src="/eshop/images/<?php echo $row['img']; ?>" border="0" alt="<?php echo $row['ti']; ?>" title="<?php echo $row['ti']; ?>" /></a>
</div>
<div class="clearh"></div>
<div class="media-body cpn marnone">
<div class="col-lg-9 col-md-6 col-sm-6 emarg">
<?php echo nl2br(htmlspecialchars($row['ts'])); ?>
</div>
<div class="col-lg-3 col-md-6 col-sm-6 well einf">
<ul>
<li>Стоимость: <font class="flright fbold"><?php echo $row['co']; ?> руб.</font></li>
<li>Категория: <font class="flright"><a href="/category/<?php echo $caturl; ?>"><?php echo $cat; ?></a></font></li>
<li>Тип товара: <font class="flright"><?php if ($row['ty'] == 0) { echo 'Файл'; } if ($row['ty'] == 1) { echo 'Текст'; } ?></font></li>
<li>Количество: <font class="flright"><?php if ($row['inf'] == 0) { echo 'Бесконечно'; } if ($row['inf'] == 1) { $units = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `c` FROM d_es_u WHERE m = '$row[id]' AND st = '0'")); if ($units['c'] > 0) { echo $units['c'].' шт.'; } else { echo 'Всё продано'; } } ?></font></li>
<li>Рейтинг продавца: <font class="flright"><?php echo $row['rat']; ?></font></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<?php }
$count += $loading_count_posts;
$posts = "$path?count=$count&token=$token&text=".urlencode($text)."$toget";
} ?>
<a href="<?php echo $posts; ?>" class="ajaxnext"></a>
<script type='text/javascript'>
$('.lightgallerys').lightGallery();
$('.tip').tooltip();
</script>
<?php
}
}
exit;
?>