<?php
  
//Навигация
ECHO "<div class='navigation'>";
ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "<a href='/modules/?path=search'>".LG('Поиск по сайту')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO LG('Блоги');
ECHO "</div>";

IF (POST('ok')){
  
  $_SESSION['search'] = ADSL(POST('search'));
  
}

IF (ISSET($_SESSION['search'])){
  
  $search = STRIPSLASHES(HTMLSPECIALCHARS($_SESSION['search']));
  
}ELSE{
  
  $search = NULL;
  
}

ECHO "<div class='list'>";

ECHO "<form method='post' action='/modules/?path=search&type=blogs' class='panel-bottom-comments-js' style='position: relative;'>";

ECHO "<input type='text' name='search' class='form-control-100' placeholder='".LG('Что ищем?')."' value='".$search."'>";

ECHO "<button type='submit' id='ajax-comments-button' class='search-button' value='go'>".ICONS('search', 16, 'fa-fw')."</button>";

IF (CONFIG('CSRF') == 1){
  
  ECHO '<input type="hidden" name="'.$token_id.'" value="'.$token_value.'">';

}

ECHO '<input type="hidden" value="go" name="ok">';

ECHO "</form>";

ECHO "</div>";
  
$column = DB::GET_COLUMN("SELECT COUNT(*) FROM `BLOGS` WHERE (`NAME` LIKE '%".$search."%' OR `MESSAGE` LIKE '%".$search."%') AND `PRIVATE` = '0'");
$spage = SPAGE($column, $page_settings);
$page = PAGE($spage);
$limit = $page_settings * $page - $page_settings;

IF ($column == 0){ 
  
  HTML::EMPTY();
  
}ELSE{
  
  ECHO "<div class='list-body'>"; 
  
}

$data = DB::GET_STRING_ALL("SELECT * FROM `BLOGS` WHERE (`NAME` LIKE '%".$search."%' OR `MESSAGE` LIKE '%".$search."%') AND `PRIVATE` = '0' ORDER BY `TIME` DESC LIMIT ".$limit.", ".$page_settings."");

WHILE ($list = $data->FETCH())
{
  
  REQUIRE (ROOT.'/modules/blogs/plugins/blogs_list.php');

}

IF ($column > 0){

  ECHO "</div>";
  
}

IF ($spage > 1){ ECHO STR_PAGE('/modules/?path=search&type=blogs&', $spage, $page); }

//Навигация
ECHO "<div class='navigation'>";
ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "<a href='/modules/?path=search'>".LG('Поиск по сайту')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO LG('Блоги');
ECHO "</div>";

REQUIRE (ROOT.'/system/connections/footer.php');
EXIT;
  
?>