-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
106 lines (85 loc) · 2.95 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
<?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: Summary</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 {
$cm_count_sql="SELECT * FROM hosts WHERE type='cm'";
$cm_reg_sql="SELECT * FROM phones WHERE status='registered'";
$cm_unreg_sql="SELECT * FROM phones WHERE status='unregistered'";
$cm_total_sql="SELECT * FROM phones";
echo '<div class="container">'."\n";
echo '<h3>OpenVoPT Summary:</h2>'."\n\n";
echo '<br>'."\n";
echo '<table width="250px">'."\n";
echo '<tr>'."\n";
echo '<td colspan="2"><b>Call Manager Statistics</b></td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '<td>Call Manager Servers Monitored:'."\n";
echo '<td width="20px">'.mysqli_num_rows(mysqli_query($db_conn,$cm_count_sql)).'</td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '<td>Registered Phones:</td>'."\n";
echo '<td>'.mysqli_num_rows(mysqli_query($db_conn,$cm_reg_sql)).'</td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '<td>Unregistered Phones:</td>'."\n";
echo '<td>'.mysqli_num_rows(mysqli_query($db_conn,$cm_unreg_sql)).'</td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '<td>Total Phones:</td>'."\n";
echo '<td>'.mysqli_num_rows(mysqli_query($db_conn,$cm_total_sql)).'</td>'."\n";
echo '</tr>'."\n";
echo '</table>'."\n";
echo '<br>'."\n";
$sw_count_sql="SELECT * FROM hosts WHERE type='sw'";
$sw_disc_sql="SELECT DISTINCT phone FROM tracking";
echo '<table width="250px">'."\n";
echo '<tr>'."\n";
echo '<td colspan="2"><b>Switch Statistics</b></td>'."\n";
echo '</tr>'."\n";
echo '<td>Switches Monitored:</td>'."\n";
echo '<td width="20px">'.mysqli_num_rows(mysqli_query($db_conn,$sw_count_sql)).'</td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '<td>Discovered Phones:</td>'."\n";
echo '<td>'.mysqli_num_rows(mysqli_query($db_conn,$sw_disc_sql)).'</td>'."\n";
echo '</tr>'."\n";
echo '</table>'."\n";
echo '</div>'."\n";
}
?>
</body>
</html>