-
Notifications
You must be signed in to change notification settings - Fork 0
/
messageboard.php
executable file
·70 lines (55 loc) · 1.93 KB
/
messageboard.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
<?php
require_once('template.php');
loadHeader();
$db = DefaultDatabase();
if (Database::countRows($db -> query("SHOW TABLES LIKE 'messageboard'", array())) == 0) {
$db -> query("
CREATE TABLE `messageboard` (
`id` INT AUTO_INCREMENT,
PRIMARY KEY(`id`),
`username` TINYTEXT,
`content` TEXT,
`createtime` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
ENGINE = MyISAM
COLLATE = utf8mb4_unicode_ci
", array());
echo 'Initialized table `messageboard`.<br />';
}
echo '<div class="main_content">';
$login = false;
if (isset($_COOKIE['uuid'])) {
$result = Post("http://" . $_SERVER['HTTP_HOST'] . "/account_new/post/verify.php", array('uuid' => $_COOKIE['uuid']));
if (isset($result) && $result != "") $login = true;
}
if ($login) {
echo '当前已登录:' . htmlFilter($result);
if (isset($_POST['content'])) {
$username = $result;
$content = $_POST['content'];
$db -> query("INSERT INTO `messageboard` (`username`, `content`) VALUES ('%s', '%s')", array($username, $content));
}
} else {
echo '<a href="account_new/login.php">登录/注册</a>';
}
echo '<hr />';
$result = $db -> query("SELECT * FROM `messageboard` ORDER BY `createtime` DESC", array());
while ($row = Database::getRowArray($result)) {
echo '<div style="padding-left:10px;text-align:left;">';
echo '<a href="">' . htmlFilter($row['username']) . '</a>: ' . htmlFilter($row['content']);
echo '</div>';
}
echo '</div>';
if ($login) {
echo '
<div class="main_content">
留言<br />
<form id="submit" action="messageboard.php" method="post">
<textarea name="content" id="content" class="inputbox" style="width:80%;min-height:100px;resize:vertical;" placeholder="内容"></textarea>
<br />
<input type="submit" class="btn" value="发布" />
</form>
</div>';
}
loadFooter();
?>