-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.php
201 lines (182 loc) · 6.27 KB
/
index.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
191
192
193
194
195
196
197
198
199
200
<?php
require_once("config.php");
require_once("parser.class.php");
//Check login session
session_start();
if (!$_SESSION['logged_in'])
{
//check fails
header("Location: login.php?status=session");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/style.css">
<title>phpdhcpd</title>
<script type="text/javascript">
function sortby (to, p) {
var myForm = document.createElement("form");
myForm.method = "post";
myForm.action = to;
for (var k in p) {
var myInput = document.createElement("input");
myInput.setAttribute("name", k);
myInput.setAttribute("value", p[k]);
myForm.appendChild(myInput);
}
document.body.appendChild(myForm);
myForm.submit() ;
document.body.removeChild(myForm);
}
</script>
</head>
<body>
<div class="center">
<h2>Current DHCP IP Addresses (Leases)</h2>
</div>
<?php
//read leases file
if (isset($_POST['searchfilter'])) {
$searchfilter = $_POST['searchfilter'];
} else {
$searchfilter = "";
}
if (isset($_POST['sort_column'])) {
$sort_column = $_POST['sort_column'];
} else {
$sort_column = 0;
}
if (isset($_POST['onlyactiveleases'])) {
$onlyactiveleases = true;
} else {
$onlyactiveleases = false;
}
if (file_exists($dhcpd_leases_file) && is_readable($dhcpd_leases_file))
{
$open_file = fopen($dhcpd_leases_file, "r") or die("Unable to open DHCP leases file.");
if ($open_file)
{
if ($searchfilter != "") {
$searchfiledmsg = $searchfilter;
} else {
$searchfiledmsg = "Type to search";
}
//Call the dhcplease file parser
$parser = new ParseClass();
$parser->parser($open_file);
?>
<form action = "index.php" accept-charset="UTF-8" method="post" id="search-form">
<input type="checkbox" name="onlyactiveleases" value="true"
<?php
if ($onlyactiveleases)
echo "checked='true'";
?>
/> Only display active leases<br>
Search Filter:
<input type="text" maxlength="255" name="searchfilter" id="searchfilter" size="20" placeholder="Enter Search"
<?php
echo " value = '" . $searchfilter . "'>";
?>
<input type="submit" name="Search" value="Search">
<?php
if ($searchfilter != "")
echo "<a href='index.php'>Clear Search</a>\n";
?>
</form>
<br><br>
<table>
<tr class="table_title">
<td style="width:14%;"><b>
<a href="javascript:sortby('index.php',{sort_column:'-1',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_down.png" alt="Sort Descending" title="Sort Descending">
</a>
IP Address
<a href="javascript:sortby('index.php',{sort_column:'1',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_up.png" alt="Sort Ascending" title="Sort Ascending">
</a>
</b></td>
<td style="width:14%;"><b>
<a href="javascript:sortby('index.php',{sort_column:'-2',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_down.png" alt="Sort Descending" title="Sort Descending">
</a>
Start Time
<a href="javascript:sortby('index.php',{sort_column:'2',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_up.png" alt="Sort Ascending" title="Sort Ascending">
</a>
</b></td>
<td style="width:14%;"><b>
<a href="javascript:sortby('index.php',{sort_column:'-3',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_down.png" alt="Sort Descending" title="Sort Descending">
</a>
End Time
<a href="javascript:sortby('index.php',{sort_column:'3',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_up.png" alt="Sort Ascending" title="Sort Ascending">
</a>
</b></td>
<td style="width:14%;"><b>
<a href="javascript:sortby('index.php',{sort_column:'-4',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_down.png" alt="Sort Descending" title="Sort Descending">
</a>
Lease Expires
<a href="javascript:sortby('index.php',{sort_column:'4',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_up.png" alt="Sort Ascending" title="Sort Ascending">
</a>
</b></td>
<td style="width:14%;"><b>
<a href="javascript:sortby('index.php',{sort_column:'-5',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_down.png" alt="Sort Descending" title="Sort Descending">
</a>
MAC Address
<a href="javascript:sortby('index.php',{sort_column:'5',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_up.png" alt="Sort Ascending" title="Sort Ascending">
</a>
</b></td>
<td style="width:14%;"><b>
<a href="javascript:sortby('index.php',{sort_column:'-6',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_down.png" alt="Sort Descending" title="Sort Descending">
</a>
Client Identifier
<a href="javascript:sortby('index.php',{sort_column:'6',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_up.png" alt="Sort Ascending" title="Sort Ascending">
</a>
</b></td>
<td style="width:14%;"><b>
<a href="javascript:sortby('index.php',{sort_column:'-7',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_down.png" alt="Sort Descending" title="Sort Descending">
</a>
Hostname
<a href="javascript:sortby('index.php',{sort_column:'7',searchfilter:'<?php echo $searchfilter;?>'})">
<img src="images/arrow_up.png" alt="Sort Ascending" title="Sort Ascending">
</a>
</b></td>
</tr>
<?php
//Display the dhcp lease table using the filter and ordered
$parser->print_table($searchfilter, $sort_column, $onlyactiveleases);
fclose($open_file);
?>
</table>
<?php
echo "<p>Total number of entries in DHCP lease table: " . count($parser->dhcptable) . "</p>\n";
echo "<p>Number of entries displayed on this page: " . $parser->filtered_number_display . "</p>\n";
}
}
else
{
echo "<p class='error'>The DHCP leases file does not exist or does not have sufficient read privileges.</p>";
}
//display message if the cache file isn't writeable
if ($cache_vendor_results && !is_writeable("./nmap-mac-prefixes_cache")) {
echo "<p class='error'>The nmap-mac-prefixes_cache file doesn't have sufficient write privileges.</p>";
}
?>
<br><hr>
<div class="center">
<a href="https://github.com/firefly2442/phpdhcpd/">phpdhcpd</a>
<br>Version: <?php echo $version;?>
</div>
</body>
</html>