-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit.php
124 lines (116 loc) · 4.12 KB
/
edit.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
<?php
/*include settings.php*/
include_once("settings.php");
include_once ("functions.php");
if(!isUser()) {
setFlash("請登入", "error");
echo '<script type="text/javascript">';
echo " window.location='index.php';";
echo "</script>";
exit;
}
$title = "修改 IP 設定";
$page = "edit";
$link = mysql_connect(MYSQL_LOCATION, MYSQL_USERNAME, MYSQL_PASSWORD) or exit("無法與MySQL建立連線");
mysql_select_db(MYSQL_DATABASE);
include ("header.php");
?>
<div class='container'>
<div class='row'>
<div class='span4'>
<h1><?php echo $title;?></h1>
</div>
<div class='span12'>
<form action='update.php' method='post'>
<fieldset>
<div class="clearfix">
<label for="IP_last_4_digits">IP位址</label>
<div class="input">
<select name='IP_last_4_digits'>
<?php
/* 產生使用中的 IP */
if($link = mysql_connect(MYSQL_LOCATION, MYSQL_USERNAME, MYSQL_PASSWORD) == false){
die("無法與資料庫伺服器連線");
}
mysql_set_charset("utf8", $link);
mysql_select_db(MYSQL_DATABASE);
$result = mysql_query("select * from ips");
if($result == FALSE){
exit("</select><br />發生錯誤:mysql_query()查詢失敗。<br />");
}
for ( $counter = 0; $row = mysql_fetch_row( $result ); $counter++)
{
$ipaddr = $row[0];
$used = $row[1];
$owner = $row[4];
if($used && ($owner==$_SESSION['userName'] || isSuperUser())) {
print('<option value="'.htmlspecialchars($ipaddr).'">'.htmlspecialchars($ipaddr).'</option>');
}
}
?>
</select>
</div>
</div>
<div class="clearfix">
<label for="machine_feature">機器功能</label>
<div class="input">
<input type='text' id='machine_feature' name='machine_feature' size='20' maxlength='50' value="web server"/>
</div>
</div>
<div class="clearfix">
<label for="machine_ports">使用的連接埠</label>
<div class="input">
<input type='text' id='machine_ports' name='machine_ports' size='20' maxlength='50' value="80"/>
</div>
</div>
<div class="clearfix">
<label for="machine_owner">負責人</label>
<div class="input">
<?php if(isSuperUser()): ?>
<select id='machine_owner' name='machine_owner'>
<?php
/* 產生使用者清單 */
$link = mysql_connect(MYSQL_LOCATION, MYSQL_USERNAME, MYSQL_PASSWORD) or exit("<option></option></select>"."您瀏覽的網頁因為「Web伺服器無法與MySQL資料庫伺服器建立連線」原因無法正常顯示,請您稍候再嘗試瀏覽,如果仍沒有恢復正常請連繫網站管理員<a href='mailto:pika1021@gmail.com' >pika1021@gmail.com</a>處理。造成您的不便非常抱歉。"."</div></div></fieldset></form></div></div></div></body></html>");
mysql_set_charset("utf8", $link);
mysql_select_db("iptable");
$result = mysql_query("select name from users");
for ( $counter = 0; $row = mysql_fetch_row( $result ); $counter++)
{
$userName = $row[0];//ip
if ($userName == $_SESSION['userName']) {
print('<option value="'.htmlspecialchars($userName).'" selected="selected">'.htmlspecialchars($userName).'</option>');
}
else
{
print('<option value="'.$userName.'">'.$userName.'</option>');
}
}
?>
</select>
<?php else: ?>
<select name='machine_owner' disabled="disabled">
<option value="<?php print($_SESSION['userName'])?>"><?php print($_SESSION['userName'])?></option>
</select>
<?php endif;?>
</div>
</div>
<div class="clearfix">
<label for="machine_location">機器所在位置</label>
<div class="input">
<input type='text' id='machine_location' name='machine_location' size='20' maxlength='50' value="no idea"/>
</div>
</div>
<div class="actions">
<input class="primary btn" type='submit' name='submit' value='修改機器' />
<input class="danger btn" type='submit' name='submit' value='清除機器' />
<input class="btn" type='reset' value='清除重填' />
</div>
</fieldset>
</form>
</div>
</div>
</div>
<?php
include ("footer.php");
mysql_close($link);
?>