<?php
  
FOREACH (ARRAY('config', 'connect', 'users') AS $connect) {
  
  INCLUDE_ONCE ("../../system/connections/global/$connect.php"); 
  
}

ACCESS('users');

IF (AJAX() == TRUE){
  
  IF (!GET('url')){
    
    ECHO "<div class='list-menu'>";
    ECHO LG('Неизвестная ошибка');
    ECHO "</div>";
    
  }ELSE{
    
    $url = HTMLSPECIALCHARS(GET('url'));
    
    ECHO "<div class='list-menu'>";
    
    ECHO "<a load='none' id='upload-atcom' class='h1' action='/users/attachments/photos.php?url=".$url."&type=".HTMLSPECIALCHARS(GET('type'))."'>".LG('Фото')."</a>";
    ECHO "<a load='none' id='upload-atcom' class='h1 h' action='/users/attachments/music.php?url=".$url."&type=".HTMLSPECIALCHARS(GET('type'))."'>".LG('Музыка')."</a>";
    ECHO "<a load='none' id='upload-atcom' class='h1' action='/users/attachments/videos.php?url=".$url."&type=".HTMLSPECIALCHARS(GET('type'))."'>".LG('Видео')."</a>";
    
    ECHO "</div>";
    
    ECHO "<div class='list-menu'>";
    
    ECHO "<center>";
    
    ECHO LG('Разрешается выгружать музыку форматов:'); 
    ECHO ' <b>.mp3</b>';
    
    ECHO "<br /><br />";
    
    ECHO LG('Максимально допустимый размер:');
    
    ECHO " <br /><span class='count'>".SIZE_FILE(CONFIG('MAXFILESIZE'))."</span>";
    
    ECHO "<br /><br />";
   
    FILE::UPLOAD('/files/receiver/attachments_music.php?url='.$url.'&type='.HTMLSPECIALCHARS(GET('type')).'', 'Загрузить', 1, 'btn-big');
    
    IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `MUSIC` WHERE `USER_ID` = '".$user['ID']."'") > 0) {
      
      ECHO "<p><b>".LG('или')."</b></p>";
    
    }
    
    ECHO "</center>";
    
    ECHO "</div>";
    
    $data = DB::GET_STRING_ALL("SELECT * FROM `MUSIC` WHERE `USER_ID` = '".$user['ID']."' ORDER BY `TIME` DESC LIMIT 10");
    
    ECHO "<div id='music_list'>";
    
    WHILE ($list = $data->FETCH()){
      
      ECHO "<div class='list-menu'>";
      
      ECHO FILE::ICONS($list['EXT'], 'small');
      
      ECHO ' <b>'.TEXT_ABSOLUTE($list['FACT_NAME']).'</b><br />';
      
      ECHO '<a href="'.BASE64_DECODE($url).'&add_atcom_music='.$list['ID'].'&url='.$url.'" class="btn-o">';
      
      ECHO "".ICONS('plus', 15, 'fa-fw')." ".LG('Выбрать')."</a>";
      
      ECHO "</div>";
    
    }
    
    ECHO "</div>";
    
    IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `MUSIC` WHERE `USER_ID` = '".$user['ID']."'") >= 10) {
      
      ECHO "<div class='list-menu'>";
      
      ?><br /><center><a onclick="show_more('/system/AJAX/php/music_list.php?url=<?=$url?>', '#show_more_avatar', '#music_list', 10)" class="btn-big" id="show_more_avatar" count_show="10" count_add="10"><?=LG('Показать еще')?></a></center><? 
        
      ECHO "</div>";
      
    }
    
  }
  
}ELSE{
  
  REDIRECT('/index');

}
  
?>