-
Notifications
You must be signed in to change notification settings - Fork 1
/
new.php
112 lines (105 loc) · 3.25 KB
/
new.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
<?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 = "new";
$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 */
$link = mysql_connect(MYSQL_LOCATION, MYSQL_USERNAME, MYSQL_PASSWORD) or die("無法與MySQL建立連線");
mysql_select_db(MYSQL_DATABASE);
$result = mysql_query("select * from ips");
for ( $counter = 0; $row = mysql_fetch_row( $result ); $counter++)
{
$ipaddr = $row[0];//ip
$used = $row[1];//used
if(!$used)
{
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' 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' 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 name='machine_owner'>
<?php
/* 產生使用者清單 */
$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="'.$userName.'" selected="selected">'.$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' 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="btn" type='reset' value='清除重填' />
</div>
</fieldset>
</form>
</div>
</div>
</div>
<?php
include ("footer.php");
mysql_close($link);
?>