-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyworddetail.php
142 lines (137 loc) · 4.64 KB
/
keyworddetail.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/*
* ybot.php - a plurk bot use php-plurk-api
*
* Copyright (C) 2012 Wei-Chen Lai <[email protected]>
* 2012 Zheng-Yen Hong
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
session_start();
if(!isset($_SESSION['_ybot_uid'])):
header('Location: login.php');
else:
require('db_port.php');
$dblink = db_init($_SESSION[_ybot_uid]);
if (isset($_POST['delres'])){
$key=$_POST['delres'];
remove_relation($dblink, $key, $_GET['keyword']);
}
if (isset($_POST['delkey'])){
remove_keywords($dblink, $_GET['keyword']);
header('Location: keywordedit.php');
}
if (isset($_POST['newres'])){
$reply = trim($_POST['reply']);
if(!empty($reply)) {
add_sentence($dblink, $_POST['qualifier'], trim($_POST['reply']));
create_relation($dblink, trim($_POST['reply']), array(trim($_GET['keyword'])));
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ybot - <?php echo htmlspecialchars($_GET['keyword'])?> detail</title>
<link rel='stylesheet' href='style.css' type='text/css'>
<style type='text/css'>
<!--
.response-box {
text-align: left;
width: 90%;
margin: 1em auto;
}
tr td:first-child {
text-align: center;
}
h1 {
text-align: left;
}
form {
text-align: center;
}
#newres {
display: block;
margin: 0 auto;
}
-->
</style>
</head>
<body>
<div class='container'>
<?php include('header.inc'); ?>
<?php include('navbar.inc'); ?>
<div>
<h1>Keyword: <?php echo htmlspecialchars($_GET['keyword']);?>
<form action='' method='POST' id='delete-form'>
<input type='hidden' name='delkey' value='1' />
<input id='delete-btn' type='button' title='Destroy this Keyword!' value='Delete this keyword' onclick='javascript:if(confirm("Are you sure?"))this.form.submit();'>
</form>
</h1>
</div>
<div class='response-box'>
<div style='text-align: center;'>Responses</div>
<table>
<tr>
<th>Qualifier</th>
<th>Response</th>
<th>Action</th>
</tr>
<?php
$result=list_relation_keyword($dblink, $_GET['keyword']);
foreach ($result as $i){
echo "<tr><td>".$i['qualifier']."</td><td><a href='responsedetail.php?response=".urlencode($i['response'])."'>".$i['response']."</a></td>";
echo "<td><form action='' method='POST'><input type='hidden' name='delres' value='".$i['response']."'><input class='unlink-btn' type='button' title='Unlink' value='Unlink' onclick='javascript: if(confirm(\"Are you sure?\")) this.form.submit();'></form></td></tr>";
}
?>
<tr>
<form action='' method='POST'>
<td>
<select name="qualifier">
<option value=":">:(自由發揮)</option>
<option value="says" selected="selected">說</option>
<option value="likes" >喜歡</option>
<option value="shares" >分享</option>
<option value="gives" >給</option>
<option value="hates" >討厭</option>
<option value="wants" >想要</option>
<option value="has" >已經</option>
<option value="will" >打算</option>
<option value="asks" >問</option>
<option value="wishs" >期待</option>
<option value="was" >曾經</option>
<option value="feels" >覺得</option>
<option value="thinks" >想</option>
<option value="is" >正在</option>
<option value="hopes" >希望</option>
<option value="needs" >需要</option>
<option value="wonders" >好奇</option>
</select>
</td>
<td>
<input type='text' name='reply' style='width: 95%; display: block; margin: auto' maxlength='140' />
</td>
<td>
<input type='submit' name='newres' value='+' id='newres' class='newkey-btn' />
</td>
</tr>
</tr>
</table>
<a href='keywordedit.php' class='back-btn'><img src='images/back.png'> Back to keywords list</a>
</div>
</body>
</html>
<?php endif; ?>