<?php
  
//Только друзьям
IF ($blog['PRIVATE'] == 1 && $blog['USER_ID'] != $user['ID'] && DB::GET_COLUMN("SELECT COUNT(*) FROM `FRIENDS` WHERE `USER_ID` = '".$user['ID']."' AND `MY_ID` = '".$blog['USER_ID']."' AND `ACT` = '0' LIMIT 1") == 0){
  
  ECHO "<div class='list'><center>";
  ECHO "".ICONS('lock', 50)."<br /><font size='+1'>".LG('Доступ только для друзей автора записи')."</font>";
  ECHO "</center></div>";
  
  //Навигация
  ECHO "<div class='navigation'>";
  ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
  ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
  ECHO "<a href='/id".$account['ID']."'>".$account['LOGIN']."</a>";
  ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
  ECHO "<a href='/modules/?path=blogs&section=users&id=".$account['ID']."'>".LG('Блог')."</a>";
  ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
  ECHO "".TEXT_ABSOLUTE($blog['NAME'])."";
  ECHO "</div>";
  
  REQUIRE (ROOT.'/system/connections/footer.php');
  EXIT;
  
}

//Только автору
IF ($blog['PRIVATE'] == 2 && $blog['USER_ID'] != $user['ID']){
  
  ECHO "<div class='list'><center>";
  ECHO "".ICONS('lock', 50)."<br /><font size='+1'>".LG('Доступ только для автора записи')."</font>";
  ECHO "</center></div>";
  
  //Навигация
  ECHO "<div class='navigation'>";
  ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
  ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
  ECHO "<a href='/id".$account['ID']."'>".$account['LOGIN']."</a>";
  ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
  ECHO "<a href='/modules/?path=blogs&section=users&id=".$account['ID']."'>".LG('Блог')."</a>";
  ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
  ECHO "".TEXT_ABSOLUTE($blog['NAME'])."";
  ECHO "</div>";
  
  REQUIRE (ROOT.'/system/connections/footer.php');
  EXIT;
  
}

//По паролю
IF ($blog['PRIVATE'] == 4 && STR($blog['PASSWORD']) > 0 && $blog['USER_ID'] != $user['ID'] && !ISSET($_SESSION['BLOGS_PASSWORD'])){
  
  IF (POST('ok')){
    
    $password = MD5(ADSL(POST('password')));
    
    IF ($password != $blog['PASSWORD']){
      
      ERROR('Неверный пароль', 'session');
      REDIRECT('/modules/?path=blogs&section=show&id='.$blog['ID'].'');
      
    }
    
    $_SESSION['BLOGS_PASSWORD'] = 1;

    REDIRECT('/modules/?path=blogs&section=show&id='.$blog['ID'].'');
    
  }
    
  ECHO "<div class='list'><center>";
  
  ECHO "".ICONS('key', 50)."<br /><font size='+1'>".LG('Доступ только по паролю')."</font>";
  
  ECHO "</center></div>";
  
  ECHO "<div class='list'>";
  
  ECHO "<form method='post' class='form' action='/modules/?path=blogs&section=show&id=".$blog['ID']."'>";
  
  ECHO "<b>".LG('Пароль')."</b>:<br />";
  HTML::INPUT('password', NULL);
  
  HTML::BUTTON('btn-big ajax-button', 'ok', NULL, 'Вперед');
  
  ECHO "</form>";
  
  ECHO "</div>";
  
  //Навигация
  ECHO "<div class='navigation'>";
  ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
  ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
  ECHO "<a href='/id".$account['ID']."'>".$account['LOGIN']."</a>";
  ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
  ECHO "<a href='/modules/?path=blogs&section=users&id=".$account['ID']."'>".LG('Блог')."</a>";
  ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
  ECHO "".TEXT_ABSOLUTE($blog['NAME'])."";
  ECHO "</div>";
  
  REQUIRE (ROOT.'/system/connections/footer.php');
  EXIT;
  
}
  
?>