<?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=users' 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 `USERS` WHERE `LOGIN` LIKE '%".$search."%'");
$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 `USERS` WHERE `LOGIN` LIKE '%".$search."%' ORDER BY `DATE_VISIT` DESC LIMIT ".$limit.", ".$page_settings."");

WHILE ($list = $data->FETCH())
{
  
  $account_settings = DB::GET_STRING("SELECT * FROM `USERS_SETTINGS` WHERE `USER_ID` = '".$list['ID']."' LIMIT 1");
  
  ECHO "<div class='list-menu'>"; 
  
  ECHO "<a href='/id".$list['ID']."'><table style='width: 100%;'><tr>";
  
  ECHO "<td class='us-avatar'>";
  ECHO USER::AVATAR($list['ID'], 50, 0, 1)."";
  ECHO "</td>";
  
  $c_f = DB::GET_STRING("SELECT * FROM `COUNTRY` WHERE `NAME` = '".TEXT_ABSOLUTE($account_settings['COUNTRY'])."' LIMIT 1");
  
  IF ($account_settings['COUNTRY'] > NULL || $account_settings['CITY'] > NULL){
    
    $crc = TEXT_ABSOLUTE($account_settings['CITY']).", ".TEXT_ABSOLUTE($account_settings['COUNTRY']);
  
  }ELSE{
    
    $crc = NULL;
  
  }
  
  $age = _AGE($list['ID'], AGE($list['ID'], $account_settings['G_R'], $account_settings['M_R'], $account_settings['D_R']), ARRAY(LG('год'), LG('года'), LG('лет')));
  
  ECHO "<td class='us-info'>";
  ECHO "".USER::LOGIN($list['ID'])."<br /><small>".$crc." ".($c_f['ID'] != NULL ? '<img src="/style/country/'.$c_f['ID'].'.png"><br />' : NULL)."";
  ECHO TEXT_ABSOLUTE($age);

  ECHO "<br /><font color='black'>".LG('Посл. визит').": ".FTIME($list['DATE_VISIT'])."</font>";
  
  IF (GET('get') == 'rating'){
    
    $s++;
    
    ECHO "<br /><br /><b><font color='black'>".LG('Рейтинг').": ".$list['RATING']."</b> - ".$s." ".LG('место')."</font>";
    
  }
  
  ECHO "</small></td>";
  
  ECHO "</tr></table></a>";
  
  ECHO "</div>";

}

IF ($column > 0){

  ECHO "</div>";
  
}

IF ($spage > 1){ ECHO STR_PAGE('/modules/?path=search&type=users&', $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;
  
?>