-
Notifications
You must be signed in to change notification settings - Fork 2
/
navi.inc.php
121 lines (104 loc) · 5.71 KB
/
navi.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<? session_start(); ?>
<div class="navbar navbar-inverse navbar-fixed-top headroom" >
<div class="container">
<div class="navbar-header">
<!-- Button for smallest screens -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/index.php"><img src="/assets/images/logo.png"></a>
</div>
<?php
$ps = new GloriousDB(DBConfig::$DB_host, DBConfig::$DB_PS_User, DBConfig::$DB_PS_Pass, DBConfig::$DB_PS_Name);
$nav_template = '<div class="navbar-collapse collapse">
<ul class="nav navbar-nav pull-right">
<li %s><a href="/index.php">首页</a></li>
<li %s><a href="#">博客</a></li>
<li %s>
<a class="dropdown-toggle" data-toggle="dropdown">训练中心<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="">Online Judge</a></li>
<li><a href="">ISDCTF</a></li>
</ul>
</li>
<li %s>
<a class="dropdown-toggle" data-toggle="dropdown">公共服务<b class="caret"></b></a>
<ul class="dropdown-menu">
%s
</ul>
</li>
<li %s>
<a class="dropdown-toggle" data-toggle="dropdown">关于我们<b class="caret"></b></a>
<ul class="dropdown-menu">
%s
</ul>
</li>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="nav-form-control" placeholder="Search" required>
</div>
</form>
%s
</ul>
</div>';
$nav_list_template = '<li><a href="%s">%s</a></li>';
$user_info_template = '<li>
<a class="dropdown-toggle" data-toggle="dropdown">%s<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="">用户中心</a></li>
%s
<hr />
<li><a href="./usercenter/logreg/signout.php">注销</a></li>
</ul>
</li>';
$login_template = '<li><a href="/usercenter/logreg/login.php">登录/注册</a></li>';
$ps->setTable('service');
$services = $ps->findall();
$ps->destroy();
$service = '';
for ($i=0; $i<count($services); $i++) {
if (!$services[$i]['enable'])
continue;
$service_name = $services[$i]['name'];
if (array_key_exists("path", $services[$i]))
$path = '/services/' .$services[$i]['path'];
else
$path = '#';
$service .= sprintf($nav_list_template, $path, $service_name);
}
$cms = new GloriousDB(DBConfig::$DB_host, DBConfig::$DB_CMS_User, DBConfig::$DB_CMS_Pass, DBConfig::$DB_CMS_Name);
$cms->setTable('intro_column');
$intros = $cms->findall();
$cms->destroy();
$intro = '';
for ($i=0; $i<count($intros); $i++) {
if (!$intros[$i]['enable'])
continue;
$column_name = $intros[$i]['name'];
if (array_key_exists("path", $intros[$i]))
$path = '/intro/' . $intros[$i]['path'];
else
$path = '#';
$intro .= sprintf($nav_list_template, $path, $column_name);
}
if(isset($_SESSION['valid_user'])) {
$userid = $_SESSION['valid_user'];
$uc = new GloriousDB(DBConfig::$DB_host, DBConfig::$DB_UC_User, DBConfig::$DB_UC_Pass, DBConfig::$DB_UC_Name);
$uc->setTable('user');
$uc->where(['username' => $userid]);
$user = $uc->find('*')[0];
if ($user['privilege'] != 0 && $user['privilege'] != 1) {
$ifPrivilege = '<li><a href="">后台管理</a></li>';
} else {
$ifPrivilege = '';
}
$userInfo = sprintf($user_info_template, $userid, $ifPrivilege);
} else {
$userInfo = $login_template;
}
echo sprintf($nav_template, $_home_class, $_blog_class, $_train_class, $_service_class, $service, $_about_class, $intro, $userInfo);
?>
</div>
</div>