<?php
$context = [];
$baseUrl = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
  require_once "inc/config.php";
  require_once "functions/top_include.php";
  processAuth(); 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <link rel="stylesheet" type="text/css" href="css/zpevnik.css">
    <title>Sbírka písniček ke zpěvu a brnkání...</title>
	<?php require_once "inc/javascript.js"; ?>
  </head>
  <body>
    <?php
      if(!isset($context['site'])){
      	$context['site'] = 'index';
      }
      switch($context['site']){
        // stránky, které nevyžadují autorizaci:
        case 'index':
          break;
        // stránky s READ autorizací:
        case 'song':
        case 'author':
        case 'search':
        case 'list':
          if(!is_auth_read()){
          	$context['site'] = 'index';
            set_message('Přístup vyžaduje autorizaci!', 'warn');
            break;
          }
          break;
        case 'edit':
          if(!is_auth_write()){
          	$context['site'] = 'index';
            set_message('Přístup vyžaduje autorizaci!', 'warn');
          }
          break;
        case 'admin':
          if(!is_auth_admin()){
          	$context['site'] = 'index';
            set_message('Přístup vyžaduje autorizaci!', 'warn');
          }
          break;
        default:
          set_message('Přístup na nedefinovanou stránku!', 'warn');
          $context['site'] = 'index';
          break;
      }
      show_message();
      
      require $context['basePath'].'/sites/'.$context['site'].'.php'; 
      show_message();
  ?>
  </body>
</html>
