<?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=music' 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>";
  
$sql = "SELECT `MUSIC`.`ID`,`MUSIC`.`USER_ID`,`MUSIC`.`NAME`,`MUSIC`.`ARTIST` FROM `MUSIC` LEFT JOIN `MUSIC_DIR` ON (`MUSIC_DIR`.`ID` = `MUSIC`.`ID_DIR` OR `MUSIC_DIR`.`ID_DIR` = `MUSIC`.`ID_DIR`) WHERE `PRIVATE` = '0' AND (`MUSIC`.`NAME` LIKE '%".$search."%' OR `MUSIC`.`FACT_NAME` LIKE '%".$search."%' OR `MUSIC`.`ARTIST` LIKE '%".$search."%' OR `MUSIC`.`GENRE` LIKE '%".$search."%') GROUP BY `MUSIC`.`ID`";

$music = DB::GET_STRING_ALL($sql);

$column = 0;

WHILE ($music->FETCH())
{
  
  $column++;
  
}

$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'>"; 
  
}

$s = 0;

$data = DB::GET_STRING_ALL($sql." ORDER BY `MUSIC`.`TIME` DESC LIMIT ".$limit.", ".$page_settings."");

WHILE ($list = $data->FETCH())
{
  
  $s++;
  
  ECHO "<div class='list-menu'>"; 
  
  ECHO "<table style='width: 100%;'><tr>";
    
  ECHO "<td class='td-file'>";
      
  ?>      
  <button action="/system/AJAX/AlphaPlayer/session.php?path=<?=$list['USER_ID']?>&type=users&dir=0&id_music=<?=$list['ID']?>" id="play-status<?=$list['ID']?>" onclick="MusicPlay(<?=$list['ID']?>)" class="play-status-off play-button-style"><i class="fa fa-play fa-fw"></i></button>
  <?
          
  ECHO FILE::ICONS('mp3'); 
    
  ECHO "</td>";
    
  ECHO "<td class='td-file2'>";
    
  ECHO "<b>".CROP_TEXT(TEXT_ABSOLUTE($list['NAME']), 0, 38)."</b><br />";
    
  ECHO "<font color='#686C6F'><small>".CROP_TEXT(TEXT_ABSOLUTE($list['ARTIST']), 0, 38)."</small></font><br />";
    
  ECHO "</td>";
    
  ECHO "</tr></table>";
  
  ECHO "</div>";
  
}

IF ($column > 0){

  ECHO "</div>";
  
}

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