-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnotification.php
65 lines (59 loc) · 2 KB
/
notification.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
<?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 ($user->islogin) {
$view = new View('theme/default.html', 'theme/nav/util.php', 'theme/sidebar.php', $blog['name'], "通知");
$view->add_script_source("ts('.ts.dropdown:not(.basic)').dropdown();");
$view->add_script("./include/js/security.js");
$notice_list = cavern_query_result("SELECT * FROM `notification` WHERE `username` = '%s' ORDER BY `time` DESC", array($user->username));
if ($notice_list['num_rows'] > 0) {
$regex = array(
"username" => "/\{([^\{\}]+)\}@(\w+)/",
"url" => "/\[(.*)\]/"
);
?>
<div class="ts big dividing header">通知 <span class="notification description">#僅顯示最近 100 則通知</span></div>
<div class="table wrapper">
<table class="ts sortable celled striped table">
<thead>
<tr>
<th>內容</th>
<th>日期</th>
</tr>
</thead>
<tbody>
<?php
do {
$message = $notice_list['row']['message'];
$time = $notice_list['row']['time'];
$url = $notice_list['row']['url'];
$message = preg_replace($regex["username"], '<a href="user.php?username=$2">$1</a>', $message);
$message = preg_replace($regex["url"], "<a href=\"${url}\">$1</a>", $message);
?>
<tr>
<td><?= $message ?></td>
<td class="collapsing"><?= $time ?></td>
</tr>
<?php } while ($notice_list['row'] = $notice_list['query']->fetch_assoc()); ?>
</tbody>
</table>
</div>
<?php
} else {
$view->show_message('inverted info', '目前沒有通知。');
}
$view->render();
} else {
http_response_code(204);
header('Location: index.php?err=nologin');
exit;
}
?>