-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhfManageWebsite.php
190 lines (184 loc) · 7.13 KB
/
hfManageWebsite.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
/*
** Zabbix
** Copyright (C) 2001-2016 Zabbix SIA
**
** 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 2 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__).'/include/config.inc.php';
require_once dirname(__FILE__).'/include/triggers.inc.php';
require_once dirname(__FILE__).'/include/media.inc.php';
require_once dirname(__FILE__).'/include/users.inc.php';
require_once dirname(__FILE__).'/include/forms.inc.php';
require_once dirname(__FILE__).'/include/js.inc.php';
$page['title'] = _('错误信息站点设置');
$page['file'] = 'hfManageWebsite.php';
require_once dirname(__FILE__).'/include/page_header.php';
$themes = array_keys(Z::getThemes());
$themes[] = THEME_DEFAULT;
$mysqli = new mysqli("127.0.0.1","root","root","zabbix");
if($mysqli->connect_errno){ //连接成功errno应该为0
$str = 'Connect Error:'.$mysqli->connect_error;
echo $str;
}
$mysqli->set_charset('utf8');
$mysql_result = $mysqli->query("SELECT * FROM `hf_manageWebsite`");
$rows = array();
while($row = $mysql_result->fetch_assoc()){
$rows[] = $row;
}
$mysql_result->free();
$mysqli->close();
?>
<div class="header-title table">
<div class="cell">
<h1>收集站设置</h1>
</div>
</div>
<p id="addLink"><a href="javascript:addContact()">添加收集站</a></p>
<div id="contactList">
<table class="list-table" style="width: 100%">
<thead>
<tr>
<th>ID</th>
<th>收集站编号</th>
<th>收集站名称</th>
<th>备注</th>
<!-- <th>修改</th>-->
<th>删除</th>
</tr>
</thead>
<tbody>
<?php
$id = 0;
foreach ($rows as $item){
$id++;
echo "<tr id='".$item['id']."'>";
echo "<td class='id'>".$id."</td>";
echo "<td class='client_id'>".$item['client_id']."</td>";
echo "<td class='client_name'>".$item['client_name']."</td>";
echo "<td class='comment'>".$item['comment']."</td>";
// echo "<td><a href='javascript:updateContact(".$item['id'].")'>修改</a></td>";
echo "<td><a href='javascript:delContact(".$item['id'].")'>删除</a></td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
<div id="addForm" style="display: none">
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" style="margin-top: 30px;">
<ul class="table-forms" id="userFormList">
<li>
<div class="table-forms-td-left"><label for="client_id">收集站编号</label></div>
<div class="table-forms-td-right"><input type="text" id="client_id" name="client_id" value="" maxlength="255" style="width: 300px;" autofocus="autofocus"> 必填</div>
</li>
<li>
<div class="table-forms-td-left"><label for="client_name">收集站名称</label></div>
<div class="table-forms-td-right"><input type="text" id="client_name" name="client_name" value="" maxlength="255" style="width: 300px;" autofocus="autofocus"> 必填</div>
</li>
<li>
<div class="table-forms-td-left"><label for="comment">备注</label></div>
<div class="table-forms-td-right">
<textarea id="comment" name="comment" value="" style="width: 300px;height: 60px;"></textarea>
</div>
</li>
<li>
<div class="table-forms-td-left"></div>
<div class="table-forms-td-right tfoot-buttons">
<button type="submit" id="add" name="add" value="添加" onclick="javascript:addSubmit()">添加</button>
<button type="button" id="cancel" name="cancel" onclick="javascript:cancelForm()" class="btn-alt">取消</button>
</div>
</li>
</ul>
</div>
</div>
<script type="text/javascript">
//显示添加联系人表单
function addContact() {
var addLink = document.getElementById("addLink");
addLink.hide();
var contactList = document.getElementById("contactList");
contactList.hide();
var addForm = document.getElementById("addForm");
addForm.show();
}
//执行添加联系人操作
function addSubmit() {
var client_id = document.getElementById("client_id").value;
var client_name = document.getElementById("client_name").value;
var comment = document.getElementById("comment").value;
//检查必填字段
if(client_id == '' || client_name == ''){
alert("请检查必填字段是否已填写");
return false;
}
var param = "cmd=addWebsite&client_id="+client_id+"&client_name="+client_name+"&comment="+comment;
ajaxFun(param);
}
//删除联系人操作
function delContact(id) {
var param = "cmd=delWebsite&id="+id;
ajaxFun(param);
}
//取消添加/修改联系人表单
function cancelForm() {
var addForm = document.getElementById("addForm");
addForm.hide();
var addLink = document.getElementById("addLink");
addLink.show();
var contactList = document.getElementById("contactList");
contactList.show();
}
//执行ajax请求
function ajaxFun(param) {
//发送ajax请求
var xmlhttp;
var responseText;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var responseNum=xmlhttp.responseText;
if(responseNum == 1){
location.reload();
return;
}
if(responseNum == -1){
alert("请检查必填字段是否已填写");
return;
}
if(responseNum == -2){
alert("收集站名称重复,请修改后重试");
return;
}
alert(responseNum);
}
}
xmlhttp.open("POST","hfAjaxFunction.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send(param);
}
</script>
<?php
require_once dirname(__FILE__).'/include/page_footer.php';