-
Notifications
You must be signed in to change notification settings - Fork 0
/
p_on_sw.php
121 lines (96 loc) · 3.23 KB
/
p_on_sw.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
<?php
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
include($root."/include/config.inc.php");
session_start();
// detect session login status
if ($_SESSION['access'] == 2) { // admin user
$db_user = $db_rw_user;
$db_pass = $db_rw_pass;
}
elseif ($_SESSION['access'] == 1) { // read only user
$db_user = $db_ro_user;
$db_pass = $db_ro_pass;
}
else { // not logged in
header("Location: login.php");
die();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>OpenVoPT: Phones > Phones on Switches</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script src="js/jquery-2.1.4.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<?php
include("menu.php");
// Connect to SQL server
$db_conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
// Check SQL connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: ".mysqli_connect_error()."<br>\n";
}
else {
$phone=$_GET['phone'];
echo '<div class="container">'."\n";
echo '<h3>Phones found on switches:</h3>'."\n\n";
// Build SQL query for phone list
$cm_phone_sql="SELECT * FROM phones ORDER BY phone";
$results=mysqli_query($db_conn,$cm_phone_sql);
echo '<div class="form-group">'."\n";
echo '<div class="col-sm-10">'."\n";
echo '<form method="GET" action="p_on_sw.php">'."\n";
echo '<select name="phone" class="form-control">'."\n";
// Build drop-down phone list
while($row=mysqli_fetch_array($results)) {
if ($row['phone'] == $phone) { $sel=' SELECTED'; }
else { $sel=''; }
echo '<option value="'.$row['phone'].'"'.$sel.'>'.$row['phone'].'</option>'."\n";
}
echo '</select>'."\n";
echo '</div>'."\n";
echo '<button type="submit" class="btn btn-primary">Search</button>'."\n";
echo '</form>'."\n";
echo '</div>'."\n";
// build table if phone name is returned
if (strlen($phone) > 0) {
echo '<table class="table table-hover">'."\n";
echo '<thead>'."\n";
echo '<tr>'."\n";
// Build SQL query for phone histroy
$history_sql="SELECT * FROM tracking WHERE phone='".$phone."'ORDER BY datetime DESC";
$results=mysqli_query($db_conn,$history_sql);
echo '<th>DATETIME</th>'."\n";
echo '<th>Phone</th>'."\n";
echo '<th>Switch Name</th>'."\n";
echo '<th>Switch Location</th>'."\n";
echo '<th>Interface</th>'."\n";
echo '<th>Interface Description</th>'."\n";
echo '</tr>'."\n";
echo '</thead>'."\n";
echo '<tbody>'."\n";
// Build Phone History List
while($row=mysqli_fetch_array($results)) {
echo '<tr>'."\n";
echo '<td>'.$row['datetime'].'</td>'."\n";
echo '<td>'.$row['phone'].'</td>'."\n";
echo '<td>'.$row['switch'].'</td>'."\n";
echo '<td>'.$row['switch_loc'].'</td>'."\n";
echo '<td>'.$row['switch_int'].'</td>'."\n";
echo '<td>'.$row['switch_int_alias'].'</td>'."\n";
echo '</tr>'."\n";
}
echo '</tbody>'."\n";
echo '</table>'."\n";
echo '</div>'."\n";
echo '</div>'."\n";
}
}
?>
<hr>
</body>
</html>