#!/bin/bash

cacheaddr="10.10.10.27"
rmysqladdr="10.10.10.37"
wmysqladdr="10.10.10.36"

rmysqllogin="mysql --default-character-set=utf8 -h$rmysqladdr -ujxadmin -p123456 jx -e"
wmysqllogin="mysql --default-character-set=utf8 -h$wmysqladdr -ujxadmin -p123456 jx -e"

echo "Content-Type:text/html;charset=utf-8"
echo ""

# 尝试获取该会话ID的用户信息
username=""
if [ -n "$HTTP_COOKIE" ]; then
  username=$(redis-cli -c -h $cacheaddr  GET $HTTP_COOKIE)
fi
# 如果获取不到，返回登录页面
if [ -z "$username" ]; then
  echo "请你先登录"
  echo "<meta http-equiv="refresh" content="3\;URL=/login.html">3秒内跳转登录页面</meta>"
  exit
fi

echo '
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>觉行教务系统</title>
    <!-- 引入Bootstrap样式 -->
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <style>
        body {
            background-color: #F6EDAC;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <!-- 导航栏标题 -->
            <div class="navbar-header">
                <img src="/static/image/jx.png" width="1350" height="150" alt="logo" />
            </div>

            <!-- 导航栏选项 -->
            <ul class="nav navbar-nav">
                <li><a href="/cgi-bin/listStu.sh">学生列表</a></li>
                <li><a href="/cgi-bin/listClass.sh">班级列表</a></li>
                <li><a href="/cgi-bin/listTest.sh">考试列表</a></li>
                <li><a href="/cgi-bin/listSubject.sh">科目列表</a></li>
                <li><a href="/cgi-bin/listScore.sh">成绩列表</a></li>
                <li><a href="/addStu.html">添加学生</a></li>
                <li><a href="/addScore.html">添加成绩</a></li>
                <li><a href="/cgi-bin/listTeacher.sh">老师列表</a></li>
                <li><a href="/cgi-bin/listLesson.sh">课程表</a></li>
                <li><a href="/addTeacher.html">添加老师</a></li>
                <li><a href="/cgi-bin/listGood.sh">三好学生</a></li>
                <li><a href="/cgi-bin/doLogout.sh">'$username'注销</a></li>
                <li><a href="#">build_number</a></li>
            </ul>
        </div>
    </nav>
'
