forked from INUI-Dev/XtreamUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservers.php
167 lines (160 loc) · 9.7 KB
/
servers.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
<?php
include "functions.php";
if (!isset($_SESSION['user_id'])) { header("Location: ./login.php"); exit; }
include "header.php";
?> <div class="wrapper">
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li>
<a href="javascript:location.reload();" style="margin-right:10px;">
<button type="button" class="btn btn-dark waves-effect waves-light btn-sm">
<i class="mdi mdi-refresh"></i> Refresh
</button>
</a>
</li>
<li>
<a href="server.php">
<button type="button" class="btn btn-success waves-effect waves-light btn-sm">
<i class="mdi mdi-plus"></i> Add Server
</button>
</a>
</li>
</ol>
</div>
<h4 class="page-title">Servers</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body" style="overflow-x:auto;">
<table id="datatable" class="table dt-responsive nowrap">
<thead>
<tr>
<th class="text-center">ID</th>
<th>Server Name</th>
<th class="text-center">Status</th>
<th>Domain Name</th>
<th>Server IP</th>
<th class="text-center">Client Slots</th>
<th>Operating System</th>
<th class="text-center">Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($rServers as $rServer) {
if (($rServer["last_check_ago"] > 0) && ((time() - $rServer["last_check_ago"]) > 360)) { $rServer["status"] = 2; } // Server Timeout
if (in_array($rServer["status"], Array(0,1))) {
$rServerText = Array(0 => "Disabled", 1 => "Online")[$rServer["status"]];
} else {
$rServerText = "Offline for ".intval((time() - $rServer["last_check_ago"])/60)." minutes";
}
?>
<tr id="server-<?=$rServer["id"]?>">
<td class="text-center"><?=$rServer["id"]?></td>
<td><?=$rServer["server_name"]?></td>
<td class="text-center" data-toggle="tooltip" data-placement="top" title="" data-original-title="<?=$rServerText?>" ><i class="<?php if ($rServer["status"] == 1) { echo "btn-outline-info"; } else { echo "btn-outline-danger"; } ?> mdi mdi-<?=Array(0 => "alarm-light-outline", 1 => "check-network", 2 => "alarm-light-outline")[$rServer["status"]]?>"></i></td>
<td><?=$rServer["domain_name"]?></td>
<td><?=$rServer["server_ip"]?></td>
<td class="text-center"><?=count(getConnections($rServer["id"]))?> / <?=$rServer["total_clients"]?></td>
<td><?=$rServer["system_os"]?></td>
<td class="text-center">
<a href="./server.php?id=<?=$rServer["id"]?>"><button type="button" data-toggle="tooltip" data-placement="top" title="" data-original-title="Edit Server" class="btn btn-outline-info waves-effect waves-light btn-xs"><i class="mdi mdi-pencil-outline"></i></button></a>
<button type="button" data-toggle="tooltip" data-placement="top" title="" data-original-title="Kill All Connections" class="btn btn-outline-warning waves-effect waves-light btn-xs" onClick="api(<?=$rServer["id"]?>, 'kill');""><i class="fas fa-hammer"></i></button>
<?php if ($rServer["can_delete"] == 1) { ?>
<button type="button" data-toggle="tooltip" data-placement="top" title="" data-original-title="Delete Server" class="btn btn-outline-danger waves-effect waves-light btn-xs" onClick="api(<?=$rServer["id"]?>, 'delete');""><i class="mdi mdi-close"></i></button>
<?php } ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
<!-- end row-->
</div> <!-- end container -->
</div>
<!-- end wrapper -->
<!-- Footer Start -->
<footer class="footer">
<div class="container-fluid">
<div class="row">
<div class="col-md-12 text-center">Xtream Codes - Admin UI</div>
</div>
</div>
</footer>
<!-- end Footer -->
<!-- Vendor js -->
<script src="assets/js/vendor.min.js"></script>
<script src="assets/libs/jquery-toast/jquery.toast.min.js"></script>
<!-- third party js -->
<script src="assets/libs/datatables/jquery.dataTables.min.js"></script>
<script src="assets/libs/datatables/dataTables.bootstrap4.js"></script>
<script src="assets/libs/datatables/dataTables.responsive.min.js"></script>
<script src="assets/libs/datatables/responsive.bootstrap4.min.js"></script>
<script src="assets/libs/datatables/dataTables.buttons.min.js"></script>
<script src="assets/libs/datatables/buttons.bootstrap4.min.js"></script>
<script src="assets/libs/datatables/buttons.html5.min.js"></script>
<script src="assets/libs/datatables/buttons.flash.min.js"></script>
<script src="assets/libs/datatables/buttons.print.min.js"></script>
<script src="assets/libs/datatables/dataTables.keyTable.min.js"></script>
<script src="assets/libs/datatables/dataTables.select.min.js"></script>
<script src="assets/libs/pdfmake/pdfmake.min.js"></script>
<script src="assets/libs/pdfmake/vfs_fonts.js"></script>
<!-- third party js ends -->
<script>
function api(rID, rType) {
if (rType == "delete") {
if (confirm('Are you sure you want to delete this server and it\'s accompanying streams? This cannot be undone!') == false) {
return;
}
} else if (rType == "delete") {
if (confirm('Are you sure you want to kill all connections to this server?') == false) {
return;
}
}
$.getJSON("./api.php?action=server&sub=" + rType + "&server_id=" + rID, function(data) {
if (data.result === true) {
if (rType == "delete") {
$("#server-" + rID).remove();
$.toast("Server successfully deleted.");
} else if (rType == "kill") {
$.toast("All server connections have been killed.");
}
$.each($('.tooltip'), function (index, element) {
$(this).remove();
});
$('[data-toggle="tooltip"]').tooltip();
} else {
$.toast("An error occured while processing your request.");
}
});
}
$(document).ready(function() {
$("#datatable").DataTable({
language: {
paginate: {
previous: "<i class='mdi mdi-chevron-left'>",
next: "<i class='mdi mdi-chevron-right'>"
}
},
drawCallback: function() {
$(".dataTables_paginate > .pagination").addClass("pagination-rounded");
},
responsive: false
});
});
</script>
<!-- App js-->
<script src="assets/js/app.min.js"></script>
</body>
</html>