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

}
  
?>