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

ACCESS('users');

IF (AJAX() == TRUE){
  
  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/avatar.php', 'Загрузить', 1, 'btn-big');
  
  IF (IS_FILE(ROOT.'/files/upload/photos/150x150/'.$settings['AVATAR'].'.jpg')){
    
    ECHO "<br /><a href='/id".$user['ID']."?avatar_delete=".$settings['AVATAR']."' class='btn-o'>".ICONS('trash', 15, 'fa-fw')." ".LG('Удалить текущий')."</a>";
    
  }
  
  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="/id'.$user['ID'].'?avatar_upgrade='.$list['ID'].'" 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']."'") > 0) {
    
    ?><br /><center><button onclick="show_more('/system/AJAX/php/avatar_photos_list.php', '#show_more_avatar', '#photos_list', 10)" class="btn-big" id="show_more_avatar" count_show="10" count_add="10"><?=LG('Показать еще')?></button></center><? 
      
  }
  
}ELSE{
  
  REDIRECT('/index');

}
  
?>