-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.php
114 lines (107 loc) · 3.96 KB
/
user.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
<?php
require_once('connection/SQL.php');
require_once('config.php');
require_once('include/view.php');
require_once('include/user.php');
$user = validate_user();
if (!$user->valid) {
http_response_code(403);
header("Location: index.php?err=account");
exit;
}
if (isset($_GET['username']) && trim($_GET['username']) != "") {
$username = trim($_GET['username']);
try {
$target_user = new User($username);
} catch (NoUserException $e) {
http_response_code(404);
header('Location: user.php?err=no');
exit;
}
$posts = cavern_query_result("SELECT * FROM `post` WHERE `username`='%s'", array($username));
$posts_count = ($posts['num_rows'] > 0 ? $posts['num_rows'] : 0);
if ($user->islogin) {
$view = new View('theme/default.html', 'theme/nav/util.php', 'theme/sidebar.php', $blog['name'], $target_user->name);
$view->add_script_source("ts('.ts.dropdown').dropdown();");
} else {
$view = new View('theme/default.html', 'theme/nav/default.html', 'theme/sidebar.php', $blog['name'], $target_user->name);
}
$view->add_script("./include/js/security.js");
if (isset($_GET['err'])) {
if ($_GET['err'] == "no") {
$view->show_message('negative', "找不到使用者");
$view->render();
exit;
}
}
?>
<div class="ts big dividing header"><?= $target_user->name ?> 的個人資料</div>
<div class="ts stackable grid">
<div class="column">
<div class="ts center aligned flatted borderless segment">
<img src="https://www.gravatar.com/avatar/<?= md5(strtolower($target_user->email)) ?>?d=https%3A%2F%2Ftocas-ui.com%2Fassets%2Fimg%2F5e5e3a6.png&s=500" class="ts rounded image" id="avatar">
</div>
</div>
<div class="stretched column">
<div class="table wrapper">
<table class="ts borderless three column table">
<thead>
<tr>
<th colspan="2">基本資料</th>
</tr>
</thead>
<tbody>
<tr>
<td>使用者名稱</td>
<td><?= $username ?></td>
</tr>
<tr>
<td>暱稱</td>
<td><?= $target_user->name ?></td>
</tr>
<tr>
<td>權限</td>
<td><?= cavern_level_to_role($target_user->level) ?></td>
</tr>
</tbody>
</table>
<table class="ts borderless two column table">
<thead>
<tr>
<th colspan="2">統計</th>
</tr>
</thead>
<tbody>
<tr>
<td>文章數</td>
<td><?= $posts_count ?></td>
</tr>
<tr>
<td colspan="2" class="right aligned"><a href="post.php?username=<?= $username ?>">看他的文章 <i class="hand outline right icon"></i></a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<?php $view->render();
} else {
if (isset($_GET['err'])) {
if ($user->islogin) {
$view = new View('theme/default.html', 'theme/nav/util.php', 'theme/sidebar.php', $blog['name'], "使用者");
$view->add_script_source("ts('.ts.dropdown').dropdown();");
} else {
$view = new View('theme/default.html', 'theme/nav/default.html', 'theme/sidebar.php', $blog['name'], "使用者");
}
$view->add_script("./include/js/security.js");
if ($_GET['err'] == "no") {
$view->show_message('negative', "找不到使用者");
$view->render();
exit;
}
} else {
header('Location: user.php?err=no');
exit;
}
}
?>