-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathindex.php
133 lines (111 loc) · 4.4 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
<HTML>
<HEAD>
<TITLE>Who's Here?!</TITLE>
<META http-equiv="refresh" content="120">
<style type="text/css">
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:10px;
color:#333333;
border-width: 1px;
border-color: #666666;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #dedede;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #ffffff;
}
</style>
</HEAD>
<BODY>
<CENTER>
<img src="whoshere-logo.png"><br>
<b><i>You Can Modify Names and Enable Notifications for Assets Below:</i></b>
<p align="center">
<a href="configpage.php" TARGET="_BLANK">Options</a>
</p>
<?php
$output = shell_exec('systemctl status whoshere.service |grep "active (running)" | wc -l');
if($output == 0)
{
echo "<font color=red><b>The Collector Service is NOT Running!</b></font><br>(run \"<b>sudo systemctl start whoshere.service</b>\" or \"<b>python run.py</b>\" if that fails)<br><br>";
}
else
{echo "(<font color=green>The Collector Service is Running</font>)<br><br>";}
?>
<TABLE class="gridtable">
<TR><TH>Name</TH><TH>Times Seen</TH><TH>First Seen</TH><TH>Last Seen</TH><TH>Strength</TH><TH colspan="2">Notify Treshold</TH><TH>Update</TH></TR>
<?php
if(isset($_POST["asset"])){$asset = $_POST["asset"];}else{$asset = "";}
if(isset($_POST["Nickname"])){$Nickname = $_POST["Nickname"];}else{$Nickname = "";}
if(isset($_POST["DBTreshold"])){$DBTreshold = $_POST["DBTreshold"];}else{$DBTreshold = "";}
if(isset($_POST["Notify"])){$Notify = 1;}else{$Notify = 0;}
if(isset($_POST["ShowMore"])){$ShowMore = $_POST["ShowMore"];}else{$ShowMore = "No";}
$ShowMore=htmlspecialchars($ShowMore);
require_once 'dbconfig.php';
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$Nickname = mysqli_real_escape_string($conn, $Nickname);
$DBTreshold = mysqli_real_escape_string($conn, $DBTreshold);
$Notify = mysqli_real_escape_string($conn, $Notify);
$asset = mysqli_real_escape_string($conn, $asset);
if(isset($asset)){
$sql = "CALL UpdateAssets('$Nickname','$Notify','$asset','$DBTreshold');";
$result = $conn->query($sql);
}
if($ShowMore == "Yes"){
$sql = "CALL ViewAllAssets();";
} else {
$sql = "CALL QuickViewAssets();";
}
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
//var_dump($row);
$Nickname = $row["Nickname"];
$DBTreshold = $row["DBTreshold"];
$Notify = $row["Notify"];
$MAC = $row["MAC"];
$TimesSeen = $row["TimesSeen"];
$FirstSeen = $row["FirstSeen"];
$LastSeen = $row["LastSeen"];
$SignalStrength = $row["SignalStrength"];
$SSIDs = $row["SSIDs"];
if($FirstSeen == "0000-00-00 00:00:00"){$FirstSeen = "";}
$FirstSeen = date('m/d/Y h:i:s A', strtotime($FirstSeen));
$LastSeen = date('m/d/Y h:i:s A', strtotime($LastSeen));
$Nickname=htmlspecialchars($Nickname);
$DBTreshold=htmlspecialchars($DBTreshold);
$Notify=htmlspecialchars($Notify);
$MAC=htmlspecialchars($MAC);
$TimesSeen=htmlspecialchars($TimesSeen);
$FirstSeen=htmlspecialchars($FirstSeen);
$LastSeen=htmlspecialchars($LastSeen);
?>
<TR><FORM METHOD="POST" ACTION="<?php echo $_SERVER['PHP_SELF']; ?>"><INPUT TYPE="hidden" NAME="asset" VALUE="<?php echo $MAC; ?>"><TD><INPUT TYPE="TEXT" NAME="Nickname" VALUE="<?php echo $Nickname; ?>"></TD><TD ALIGN="CENTER"><?php if($SSIDs >= 1){?><A HREF="assetinfo.php?MAC=<?php echo $MAC; ?>" TARGET="_BLANK"><?php echo $TimesSeen; ?></a><?php } else { echo $TimesSeen; }?></TD><TD><?php echo $FirstSeen; ?></TD><TD><?php echo $LastSeen; ?></TD><TD ALIGN="CENTER"><?php echo $SignalStrength; ?></TD><TD ALIGN="CENTER"><INPUT TYPE="CHECKBOX" NAME="Notify" <?php if($Notify == 1){echo "checked";}else{echo "unchecked";}?>></TD><TD><INPUT TYPE="TEXT" NAME="DBTreshold" VALUE="<?php echo $DBTreshold; ?>" SIZE="3"></TD><TD ALIGN="CENTER"><INPUT TYPE="SUBMIT" VALUE="Save"></TD></FORM></TR>
<?php
}
}
$conn->close();
?>
</TABLE>
<br><br>
<?php if($ShowMore == "No"){?><FORM METHOD="POST" ACTION="<?php echo $_SERVER['PHP_SELF']; ?>"><INPUT TYPE="HIDDEN" NAME="ShowMore" VALUE="Yes"><INPUT TYPE="SUBMIT" VALUE="Show All"></FORM><?php } ?>
</CENTER>
</BODY>
</HTML>