<?php
if(empty($cookie::get('uid'))) {
    $url='/login.html?url='.urlencode('https://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]);
    go($url);
    die();
}
$uid=$cookie::get('uid');
$userinfo=(new \user\account)->info($uid);

function user_head($title='用户中心'){
    global $conf;
    global $cookie,$userinfo;
    ?>
    <!doctype html>
    <html class="no-js fixed-layout">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title><?=$title?> - <?=$conf['sysname']?></title>
        <meta name="keywords" content="<?=$conf['keyword']?>">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="renderer" content="webkit">
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <link rel="icon" type="image/png" href="/assets/amazeui/i/favicon.png">
        <link rel="apple-touch-icon-precomposed" href="/assets/amazeui/i/app-icon72x72@2x.png">
        <meta name="apple-mobile-web-app-title" content="Amaze UI" />
        <link rel="stylesheet" href="/assets/amazeui/css/amazeui.min.css"/>
        <link rel="stylesheet" href="/assets/amazeui/css/admin.css">
    </head>
    <body>
    <!--[if lte IE 9]>
    <p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
        以获得更好的体验！</p>
    <![endif]-->

    <header class="am-topbar admin-header">
        <div class="am-topbar-brand">
            <strong><?=$conf['sitename']?></strong> <small>用户中心</small>
        </div>

        <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span class="am-icon-bars"></span></button>

        <div class="am-collapse am-topbar-collapse" id="topbar-collapse">
            <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list">
                <li><a href="/"><span class="am-icon-home"></span> 首页 </a></li>
                <li class="am-dropdown" data-am-dropdown>
                    <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
                        <span class="am-icon-users"></span> <?=$userinfo['name']?> <span class="am-icon-caret-down"></span>
                    </a>
                    <ul class="am-dropdown-content">
                        <li><a href="/user/info.html"><span class="am-icon-user"></span>用户资料</a></li>
                        <li><a href="/logout.cgi"><span class="am-icon-power-off"></span>退出登录</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </header>

    <div class="am-cf admin-main">
    <!-- sidebar start -->
    <div class="admin-sidebar am-offcanvas" id="admin-offcanvas">
        <div class="am-offcanvas-bar admin-offcanvas-bar">
            <ul class="am-list admin-sidebar-list">
                <li><a href="/user/index.html"><span class="am-icon-home"></span> 首页</a></li>
                <li><a href="/user/info.html" class="am-cf"><span class="am-icon-user"></span> 用户资料<span class="am-icon-star am-fr am-margin-right admin-icon-yellow"></span></a></li>
                <?php
                if(!empty($cookie::get('admin'))){
                    echo '<li><a href="/admin/"><span class="am-icon-signal"></span>管理面板</a></li>';
                }
                ?>
                <li><a href="/logout.cgi"><span class="am-icon-sign-out"></span> 退出登录</a></li>
            </ul>

            <div class="am-panel am-panel-default admin-sidebar-panel">
                <div class="am-panel-bd">
                    <p><span class="am-icon-bookmark"></span> 公告</p>
                    <p>时光静好，与君语；细水流年，与君同。—— Amaze UI</p>
                </div>
            </div>

            <div class="am-panel am-panel-default admin-sidebar-panel">
                <div class="am-panel-bd">
                    <p><span class="am-icon-tag"></span> 版权</p>
                    <p><?=$conf['footer']?></p>
                </div>
            </div>
        </div>
    </div>
    <!-- sidebar end -->
    <?
}

function user_foot(){
    ?>
    </div>
    <a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: '#admin-offcanvas'}"></a>
    <!--[if lt IE 9]>
    <script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
    <script src="/assets/amazeui/js/amazeui.ie8polyfill.min.js"></script>
    <![endif]-->
    <!--[if (gte IE 9)|!(IE)]><!-->
    <script src="/assets/amazeui/js/jquery.min.js"></script>
    <!--<![endif]-->
    <script src="/assets/amazeui/js/amazeui.min.js"></script>
    <script src="/assets/amazeui/js/app.js"></script>
    </body>
    </html>
    <?php
}