<?php
/*
  if($thisPage != "ajax" && $thisPage != "activate" && isset($user['id']) && $user['act'] == 0)
	{
	require(MODULE."activate/index.php");  #Проверка на email [status: off]
	}  
*/
	
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
	<head>
	    <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> 
        <title><?=(isset($title) ? $title : 'Vineti общения ' )?></title>
		<meta name="generator" content="<?=$config['META_GENERATOR']?>" />
		<meta name="keywords" content="<?=$config['META_KEYWORDS']?>" />
		<meta name="description" content="<?=$config['META_DESCRIPTION']?>" />
		<meta name="author" content="<?=$config['META_AUTHOR']?>" />
		<meta name="reply-to" content="<?=$config['META_REPLY_TO']?>" />
		<meta name="copyright" content="<?=$config['META_COPYRIGHT']?>" />
		<meta http-equiv="Cache-Control" content="no-cache">
        <link rel="shortcut icon" href="/template/icons/favicon.ico" type="image/x-icon">
        <link rel="stylesheet" href="/template/css/main.css?v=<?= filemtime(ROOT . 'template/css/main.css') ?>" type="text/css" />
		<link rel="stylesheet" href="/template/css/app.css" type="text/css" />
		<link rel="stylesheet" href="/template/css/SmileButton.css?v=2" type="text/css" />
		<link rel="stylesheet" href="/template/css/nprogress.css" type="text/css" />
		<link rel="stylesheet" href="/template/css/jquery.formstyler.css" type="text/css" />
		<link rel="stylesheet" href="/template/css/font-awesome.css">
		<link rel="stylesheet" href="/template/css/redesing.css">
		<link rel="stylesheet" href="/template/css/mailcss.css">
	    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
		<script src="/template/js/TimerVisibl.js?v=2" type="text/javascript"></script>
		<script type="text/javascript" src="/template/audio/js/mainAudio.js?v=<?= filemtime(ROOT . 'template/audio/js/mainAudio.js') ?>"></script>
		<script src="/template/js/main.js?v=<?= filemtime(ROOT . 'template/js/main.js') ?>" type="text/javascript"></script>
		<script src="/template/js/jquery.ajaxRequest.js?v=<?= filemtime(ROOT . 'template/js/jquery.ajaxRequest.js') ?>" type="text/javascript"></script>
		<script src="/template/js/main.ajaxRequest.js?v=<?= filemtime(ROOT . 'template/js/main.ajaxRequest.js') ?>" type="text/javascript"></script>
		<script src="/template/js/jquery.formstyler.min.js" type="text/javascript"></script>
		<script src="/template/js/SmileButton.js?v=<?= filemtime(ROOT . 'template/js/SmileButton.js') ?>" type="text/javascript"></script>
		<script src="/template/js/nprogress.js?5" type="text/javascript"></script>
<!-- Yandex.Metrika counter -->
<script type="text/javascript" >
    (function (d, w, c) {
        (w[c] = w[c] || []).push(function() {
            try {
                w.yaCounter48945326 = new Ya.Metrika({
                    id:48945326,
                    clickmap:true,
                    trackLinks:true,
                    accurateTrackBounce:true,
                    webvisor:true
                });
            } catch(e) { }
        });

        var n = d.getElementsByTagName("script")[0],
            s = d.createElement("script"),
            f = function () { n.parentNode.insertBefore(s, n); };
        s.type = "text/javascript";
        s.async = true;
        s.src = "https://mc.yandex.ru/metrika/watch.js";

        if (w.opera == "[object Opera]") {
            d.addEventListener("DOMContentLoaded", f, false);
        } else { f(); }
    })(document, window, "yandex_metrika_callbacks");
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/48945326" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->


	<?php if(!AJAX) : ?>
       <script>
          var USER = {
          	'id': "<?=( isset($user['id']) ? $user['id'] : 0 )?>",
          	'Page': "<?=( isset($user['id']) ? profile :: getLink($user) : 0 )?>",
          	'time': "<?=time()?>",
          	'title': "<?=(isset($title) ? $title : 'Сайт')?>",
          	'name': "<?=(isset($user['id']) ? profile :: getName($user) : '' )?>",
          	'avatar': "<?=(isset($user['id']) ? profile :: getAvatar($user,'64/') : '' )?>",
          	'access' : "<?=ACCESS?>"
		};
		</script>
   		<?php endif; ?>

</head>
<body>

	<div id="scrollup" class=""></div>	
	<div class="top--pb"></div>
	<div id="top">
		<div class="top--cont">
			<div class="top--r">
				<?php if(isset($user['id'])) { ?>
				<a href="<?=profile :: getLink($user)?>">
				<div class="top--flex"><?=profile :: userAvatar($user,3)?> <span><?=profile :: getfirstname($user)?></span></div></a>
				<?php } ?>
			</div>
			<div class="top--flex">
			<div class="top--logo"><img src="/template/icons/logo.png"></div>
			<div class="top--title"><?=(isset($l) ? (isset($lBack) ? "<a href=\"{$lBack}\">{$l}</a>" : "<span>".$l."</span>") : '' )?></div>
			</div>
		</div>
	</div>
	
	<div id="container">
    <div id="head">
		<table style="width: 100%;" cellspacing="0" cellpadding="0"><tbody><tr>
			<?php
			if(isset($user)) {
				
				?>

			<td class="head-td">
				<a href="/" onclick="UI.sidebarToggle(); return false;"><i class="fa fa-bars fa-3x"></i></a>
			</td>
            <td class="head-td">
                <a href="/mail/">
                    <i class="fa fa-envelope fa-3x"></i>
                    <span id="update_msg_head_wap">
                        <?
                        $new_msg = DB::$pdo -> querySingle("SELECT COUNT(*) FROM `mail` AS m,
		        (SELECT MAX(id) AS id FROM `mail` WHERE `unlink` != :id AND (`id_kont` = :id) GROUP BY IF(`id_user` = :id, `id_kont`, `id_user`)) as max
		        WHERE m.id = max.id AND m.read = '0' AND (m.id_kont = :id) AND m.unlink != :id", array(':id'
		         => $user['id']));

                        ?>
                            <span class="head-count" style="<?= ($new_msg > 0 ? '' : 'display:none')?>">
                                <?
                                if ($new_msg > 99)
                                {
                                    echo '99+';
                                } else {
                                    echo $new_msg;
                                }
                                ?>
                            </span>

                    </span>
                </a>
            </td>
			<td class="head-td">
				<a href="/notice?tab=2"><i class="fa fa-bell fa-3x "></i>
				<span id="update_notice_head_wap">

                            <span class="head-count" style="<?= ($user['count_new_notice'] > 0 ? '' : 'display:none')?>">
                                <?
                                if ($user['count_new_notice'] > 99)
                                {
                                    echo '99+';
                                } else {
                                    echo $user['count_new_notice'];
                                }
                                ?>
                            </span>
				</span>
				</a>
			</td>
			<td class="head-td">
				<a href="<?=profile :: getLink($user)?>"><img src="<?=profile :: getAvatar($user,3)?>" style="width: 26px;border-radius: 50%;"/></a>
			</td>		
			<?php } else { ?>
			<td class="head-td">
				<a href="/"><img src="/template/icons/logo.png" /></a>
			</td>
			<?php } ?>
		</tr></tbody></table>
	</div>

	

	<div id="sidebar">
		<div class="sidebar-main">
			<div class="sidebar--links">
			<?php if(isset($user['id'])) { ?>
				 <div>
                        <a href="/mail/" class="sidebar--link">
                            <i class="fa fa-envelope fa-2x fa-mob"></i>
                            <div class="sidebar--text">
                                <?=language::text('mail', $language,'sidebar');?> 
                                <span id="update_msg_head_web" style="margin-left: 5px;">
                                    <div class="sidebar--count" style="<?= ($new_msg > 0 ? '' : 'display:none') ?>"><?echo $new_msg;?></div>
                                </span>
                            </div>
                        </a>
                    </div>
				 <div>
                     <a href="/notice?tab=2" class="sidebar--link">
                       <i class="fa fa-bell fa-2x fa-mob"></i>
                        <div class="sidebar--text">
                            <?=language::text('notice', $language,'sidebar');?>
                            <span id="update_notice_head_web" style="margin-left: 5px;">
                                <div class="sidebar--count" style="<?= ($user['count_new_notice'] > 0 ? '' : 'display:none') ?>"><?echo $user['count_new_notice'];?></div>
                            </span>
                        </div>
                     </a>
				 </div>

<div>
                     <a href="/audio" class="sidebar--link">
                        <i class="fa fa-music fa-2x fa-mob"></i>
                        <div class="sidebar--text">
                            <?=language::text('music', $language,'sidebar');?>
                            
                        </div>
                     </a>
				 </div>
				 <div id="lm_player" class="lm_player">
                     <div class="sidebar--link">
                        <div id="lm_audio" class="audio_item ai_current al_player">
                            <div class="ai_body">
                                <div class="ai_label">
                                    <div class="ai_title"></div>
                                    <span class="dividers"> – </span>
                                    <div class="ai_artist"></div>
                                </div>
                                <div>
                                    <div class="audio_prev" onclick="audio.prev();">
                                        <i class="icon"></i>
                                    </div>
                                    <div class="audio_play" onclick="audioplayer.playPause();">
                                        <i class="icon"></i>
                                    </div>
                                    <div class="audio_repeat" onclick="audio.repeat();">
                                        <i class="icon"></i>
                                    </div>
                                    <div class="audio_next" onclick="audio.next();">
                                        <i class="icon"></i>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                 </div>
				
				<?php  } else { ?>
				 <div><a href="/" class="sidebar--link">
				  <i class="fa fa-sign-in fa-2x fa-mob"></i>
				  	<div class="sidebar--text">Вход</div>
				 </a></div>
				 <div><a href="/signup" class="sidebar--link">
				 <i class="fa fa-user-plus fa-2x fa-mob"></i>
				  	<div class="sidebar--text">Регистрация</div>
				 </a></div>
				 <div><a href="/audio" class="sidebar--link">
				 <i class="fa fa-music fa-2x fa-mob"></i>
				  	<div class="sidebar--text">Музыка</div>
				 </a></div>
				<?php } ?>
			
				 <div class="sidebar--line"></div>

				 <div><a href="/arbour" class="sidebar--link">
				 <i class="fa fa-comments-o fa-2x fa-mob"></i>
				  	<div class="sidebar--text"><?=language::text('chat', $language,'sidebar');?></div>
				 </a></div>
				 <div><a href="/people?tab=2" class="sidebar--link">
				<i class="fa fa-users fa-2x fa-mob"></i>
				  	<div class="sidebar--text"><?=language::text('people', $language,'sidebar');?></div>
				 </a></div>
               
                   
                
			<?php if(isset($user['id'])) { ?>
			
			
		
			<div><a href="/groups" class="sidebar--link">
				<i class="fa fa-globe fa-2x fa-mob"></i>
				  	<div class="sidebar--text">Группы</div>
				 </a></div>
		
		
		
			
			
			
				<?php if(admin :: getAccess($user,  array('a'=>3))) { ?> <div class="sidebar--line"></div>
					<div><a href="/admin" class="sidebar--link">
				<i class="fa fa-user-secret fa-2x fa-mob"></i>
				  	<div class="sidebar--text"><?=language::text('admin', $language,'sidebar');?></div>
				 </a></div>
<?}?>
			<?php if (isset($user['id']) && DB::$pdo -> querySingle("SELECT COUNT(*) FROM `bag_tracker_users` WHERE `id_user` = '".$user['id']."'") > 0){?> 
					<div><a href="/bag_tracker" class="sidebar--link">
				 	<i class="fa fa-bug fa-2x fa-mob"></i>
				  	<div class="sidebar--text"><?=language::text('bug', $language,'sidebar');?></div>
				 </a></div>

			<?}?>
<div class="sidebar--line"></div>
				 <div><a href="/settings" class="sidebar--link">
				<i class="fa fa-gear fa-2x fa-mob"></i>
				  	<div class="sidebar--text"><?=language::text('settings', $language,'sidebar');?></div>
				 </a></div>
				 <div><a data-noajax="" href="/?logout=1&amp;access=<?=$user['access']?>" class="sidebar--link">
				 	<i class="fa fa-power-off fa-2x fa-mob"></i>
				  	<div class="sidebar--text"><?=language::text('exit', $language,'sidebar');?></div>
				 </a></div>


	


				<?php } ?>
				
				 <div class="sidebar--foot">
				 <?$lang_config = parse_ini_file(CORE.'languages/'.$language.'/config.ini');?>
	<a href="/language" style="color: #81898e;">Язык: <?echo $lang_config['name'];?></a><br>
				 	&copy; <?=$config['SITE_COPY']?>, <?=date("Y")?> <br><br>
				 	<a href="http://statok.net/go/18034"><img src="//statok.net/imageOther/18034" alt="Statok.net" /></a>
				 </div>

			</div>
		</div>
	</div>



<div id="main">
<?php
    if(isset($l)) {?>
	<?=(isset($lBack) ? "<a href=\"{$lBack}\" id=\"app-ajax-back\" style=\"text-decoration: none;\">" : '')?>
<div id="location">
	<?=$l?>
</div>
<?=(isset($lBack) ? "</a>" : '')?>
<?php
}
echo system :: notes();
?>
       