-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponseedit.php
129 lines (127 loc) · 4.47 KB
/
responseedit.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
<?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');
require('db_port.php');
$dblink = db_init($_SESSION[_ybot_uid]);
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ybot - Responedit</title>
<link rel='stylesheet' href='style.css' type='text/css'>
<style type='text/css'>
<!--
tr td:first-child {
text-align: center;
}
-->
</style>
</head>
<body>
<div class='container'>
<?php include('header.inc'); ?>
<?php include('navbar.inc'); ?>
<div class='search'>
<form action='' method='GET'>
<input type='text' name='searchw'>
<input id='search-btn' type='submit' value='search'>
</form>
</div>
<div class='add-box'>
<h3>Add new response and keywords</h3>
<form name='tableadd' action='' method='POST'>
Keywords <input type='text' name='keyword'><div style='font-size: 90%; display: block;'>separate each keywords with "|"</div>
Response
<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>
<input type='text' name='reply' maxlength='140'><br /><input type='submit' name='tableadd' value='Add'>
</form>
<?php
if (isset($_POST['tableadd'])){
if (!empty($_POST['keyword']) && !empty($_POST['reply'])){
$keyword=$_POST['keyword'];
$qualifier=$_POST['qualifier'];
$reply=$_POST['reply'];
$keyword=trim($keyword);
$keyword=explode('|',$keyword);
add_keywords($dblink,$keyword);
add_sentence($dblink,$qualifier,$reply);
create_relation($dblink,$reply,$keyword);
}
else
echo "<script type='text/javascript'>alert('you must fill all the blanks!');</script>";
}
?>
</div>
<div>
<?php
if (isset($_GET['searchw'])){
$key=trim($_GET['searchw']);
$result=output_table_response($dblink, $key, true);
$key_dis = htmlspecialchars($key);
$count = count($result);
echo "<div class='notice-green'> $count result(s) of $key_dis. <a href='responseedit.php'>Display all</a></div>";
}
?>
<h1>Responses</h1>
<table>
<tr>
<th>Qualifier</th>
<th>Response</th>
</tr>
<?php
if (!isset($_GET['searchw'])){
$result=output_table_response($dblink);
foreach($result as $i)
echo "<tr><td>".$i['qualifier']."</td><td><a href='responsedetail.php?response=".urlencode($i['response'])."'>".htmlspecialchars($i['response'])."</a></td></tr>";
}
if (isset($_GET['searchw'])){
foreach($result as $i)
echo "<tr><td>".$i['qualifier']."</td><td><a href='responsedetail.php?response=".urlencode($i['response'])."'>".htmlspecialchars($i['response'])."</a></td></tr>";
}
?>
</table>
<div style='text-align: center'><a class='top-btn' href='#top'><img src='images/top.png' />Top</a></div>
</div>
</div>
</body>
</html>