<?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 h' action='/users/attachments/photos.php?url=".$url."&type=".HTMLSPECIALCHARS(GET('type'))."'>".LG('Фото')."</a>";
    ECHO "<a load='none' id='upload-atcom' class='h1' 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>.jpg</b>, <b>.png</b> '.LG('и').' <b>.gif</b>';
    
    ECHO "<br /><br />";
    
    ECHO LG('Максимально допустимый размер:');
    
    ECHO " <br /><span class='count'>".SIZE_FILE(CONFIG('MAXFILESIZE'))."</span>";
    
    ECHO "<br /><br />";
    
    FILE::UPLOAD('/files/receiver/attachments_photos.php?url='.$url.'&type='.HTMLSPECIALCHARS(GET('type')).'', 'Загрузить', 1, 'btn-big');
    
    IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `PHOTOS` WHERE `USER_ID` = '".$user['ID']."'") > 0) {
      
      ECHO "<p><b>".LG('или')."</b></p>";
    
    }
    
    ECHO "</center>";
    
    $data = DB::GET_STRING_ALL("SELECT * FROM `PHOTOS` WHERE `USER_ID` = '".$user['ID']."' ORDER BY `TIME` DESC LIMIT 10");
    
    ECHO "<ul class='photos-body-avatar' id='photos_list'>";
    
    WHILE ($list = $data->FETCH()){
      
      ECHO "<li class='photos-wrapper-avatar'>";
      
      ECHO '<a href="'.BASE64_DECODE($url).'&add_atcom_photos='.$list['ID'].'&url='.$url.'" class="photos-avatar">';
      
      ECHO '<span class="avatar-choose"><i class="fa fa-plus fa-lg"></i></span>';
      
      ECHO "<img src='/photo/150x150/".$list['ID_DIR']."/".$list['ID']."/' style='max-width: 100%; position: absolute;'>";
      
      ECHO "</a></li>";
    
    }
    
    ECHO "</ul>";
    
    IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `PHOTOS` WHERE `USER_ID` = '".$user['ID']."'") >= 10) {
      
      ?><br /><center><a onclick="show_more('/system/AJAX/php/photos_list.php?url=<?=$url?>', '#show_more_avatar', '#photos_list', 10)" class="btn-big" id="show_more_avatar" count_show="10" count_add="10"><?=LG('Показать еще')?></a></center><? 
      
      }
    
    ECHO "</div>";
    
  }
  
}ELSE{
  
  REDIRECT('/index');

}
  
?>