-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.php
563 lines (504 loc) · 15.3 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
<?php
# Steven Sullivan Ltd
error_reporting(NULL);
$TAB = 'TOOLS';
// Main include
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
// Check user
if ($_SESSION['user'] != 'admin') {
header("Location: /list/user");
exit;
}
include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
top_panel($user,$TAB);
?>
<div class="l-center units"><div class="l-unit"></div>
<h1>Tools</h1>
<p>A list of useful tools for VestaCP Administrators.</p>
<ul class="tab">
<li><a href="#Users" class="tablinks" id="FirstTab" onclick="doTab(event, 'Users')">Users</a></li>
<li><a href="#Domains" class="tablinks" onclick="doTab(event, 'Domains')">Domains</a></li>
<li><a href="#Databases" class="tablinks" onclick="doTab(event, 'Databases')">Databases</a></li>
<li><a href="#DNSDomains" class="tablinks" onclick="doTab(event, 'DNSDomains')">DNS Domains</a></li>
<li><a href="#MailDomains" class="tablinks" onclick="doTab(event, 'MailDomains')">Mail Domains</a></li>
<li><a href="#CronJobs" class="tablinks" onclick="doTab(event, 'CronJobs')">Cron Jobs</a></li>
<li><a href="#LEUsers" class="tablinks" onclick="doTab(event, 'LEUsers')">Let's Encrypt Users</a></li>
</ul>
<?php
$UserData = shell_exec(VESTA_CMD.'v-list-users json');
$UserData = json_decode($UserData, true);
ksort($UserData);
?>
<div id="Users" class="tabcontent">
<?php
echo '<table class="sortable responstable">
<thead>
<tr>
<th width="100">Username</th>
<th class="sorttable_nosort">First/Last Name</th>
<th>Email</th>
<th>Package</th>
<th>Disk</th>
<th>Bandwidth</th>
<th width="50">Suspended</th>
<th>Created</th>
</tr>
</thead>
<tbody>';
foreach($UserData as $Username => $Array)
{
$DiskPercent = (($Array['U_DISK'] / $Array['DISK_QUOTA']) * 100);
$DiskPercent = ($DiskPercent>100) ? 100 : $DiskPercent;
$BandPercent = (($Array['U_BANDWIDTH'] / $Array['BANDWIDTH']) * 100);
$BandPercent = ($DiskPercent>100) ? 100 : $BandPercent;
echo '<tr>
<td align="left"><a href="/login/?loginas='. $Username .'" title="Login to this account">'. $Username .' <i class="fa fa-sign-in" style="color:green;"></i></a></td>
<td>'. $Array['FNAME'] . ' ' . $Array['LNAME'] . '</td>
<td>'. $Array['CONTACT'] .'</td>
<td>'. $Array['PACKAGE'] .'</td>
<td sorttable_customkey="'. $DiskPercent .'"><div class="progress"><div class="prgbar" style="width:'. $DiskPercent .'%;"></div></div></td>
<td sorttable_customkey="'. $BandPercent .'"><div class="progress"><div class="prgbar" style="width:'. $BandPercent .'%;"></div></div></td>
<td>'. $Array['SUSPENDED'] .'</td>
<td>'. $Array['DATE'] .'</td>
</tr>';
}
echo '</tbody>
</table>';
?>
</div>
<div id="Domains" class="tabcontent">
<?php
//$Users = shell_exec(VESTA_CMD.'v-list-users json');
//$Users = json_decode($Users, true);
$Array = $Data = $tmpData = $AData = array();
foreach($UserData as $Username=>$Array)
{
$Data = shell_exec(VESTA_CMD.'v-list-web-domains '. $Username .' json');
$tmpData[$Username] = json_decode($Data, true);
$tmpData[$Username]['tmp']['DISK_QUOTA'] = $Array['DISK_QUOTA'];
$tmpData[$Username]['tmp']['BANDWIDTH'] = $Array['BANDWIDTH'];
}
$Data = $tmpData;
ksort($Data);
echo '<table class="sortable responstable">
<thead>
<tr>
<th width="100">Username</th>
<th>Domain</th>
<th width="100">IP Address</th>
<th width="30">SSL</th>
<th>Disk</th>
<th>Bandwidth</th>
<th width="50">Suspended</th>
<th>Created</th>
</tr>
</thead>
<tbody>';
foreach($Data as $Username => $AData)
{
foreach($AData as $Website => $Array)
{
if($Website=='tmp') continue;
$DiskPercent = (($Array['U_DISK'] / $Data[$Username]['tmp']['DISK_QUOTA']) * 100);
$DiskPercent = ($DiskPercent>100) ? 100 : $DiskPercent;
$BandPercent = (($Array['U_BANDWIDTH'] / $Data[$Username]['tmp']['BANDWIDTH']) * 100);
$BandPercent = ($BandPercent>100) ? 100 : $BandPercent;
echo '<tr>
<td align="left"><a href="/login/?loginas='. $Username .'" title="Login to this account">'. $Username .' <i class="fa fa-sign-in" style="color:green;"></i></a></td>
<td><a href="http://'.$Website.'" title="Visit this website" target="_blank">'. $Website . ' <i class="fa fa-eye" style="color:green;"></i></a></td>
<td>'. $Array['IP'] .'</td>
<td>'. $Array['SSL'] .'</td>
<td sorttable_customkey="'. $DiskPercent .'"><div class="progress"><div class="prgbar" style="width:'. $DiskPercent .'%;"></div></div></td>
<td sorttable_customkey="'. $BandPercent .'"><div class="progress"><div class="prgbar" style="width:'. $BandPercent .'%;"></div></div></td>
<td>'. $Array['SUSPENDED'] .'</td>
<td>'. $Array['DATE'] .'</td>
</tr>';
}
}
echo '</tbody>
</table>';
?>
</div>
<div id="Databases" class="tabcontent">
<?php
//$Users = shell_exec(VESTA_CMD.'v-list-users json');
//$Users = json_decode($Users, true);
$Array = $Data = $tmpData = $AData = array();
foreach($UserData as $Username=>$Array)
{
$Data = shell_exec(VESTA_CMD.'v-list-databases '. $Username .' json');
$tmpData[$Username] = json_decode($Data, true);
}
$Data = $tmpData;
ksort($Data);
echo '<table class="sortable responstable">
<thead>
<tr>
<th width="100">Username</th>
<th>DB Name</th>
<th>DB User</th>
<th width="50">Host</th>
<th width="50">Disk Usage</th>
<th width="50">Suspended</th>
<th width="70">Created</th>
</tr>
</thead>
<tbody>';
foreach($Data as $Username => $AData)
{
foreach($AData as $Cron => $Array)
{
echo '<tr>
<td align="left"><a href="/login/?loginas='. $Username .'" title="Login to this account">'. $Username .' <i class="fa fa-sign-in" style="color:green;"></i></a></td>
<td>'. $Array['DATABASE'] . '</td>
<td>'. $Array['DBUSER'] .'</td>
<td>'. $Array['HOST'] .'</td>
<td sorttable_customkey="'. $Array['U_DISK'] .'">'. $Array['U_DISK'] .'MB</td>
<td>'. $Array['SUSPENDED'] .'</td>
<td>'. $Array['DATE'] .'</td>
</tr>';
}
}
echo '</tbody>
</table>';
?>
</div>
<div id="DNSDomains" class="tabcontent">
<?php
$Array = $Data = $tmpData = $AData = array();
foreach($UserData as $Username=>$Array)
{
$Data = shell_exec(VESTA_CMD.'v-list-dns-domains '. $Username .' json');
$tmpData[$Username] = json_decode($Data, true);
}
$Data = $tmpData;
ksort($Data);
echo '<table class="sortable responstable">
<thead>
<tr>
<th width="100">Username</th>
<th>Domain</th>
<th width="100">IP Address</th>
<th width="50">Total Records</th>
<th width="50">Suspended</th>
<th width="70">Created</th>
</tr>
</thead>
<tbody>';
foreach($Data as $Username => $AData)
{
foreach($AData as $Domain => $Array)
{
echo '<tr>
<td align="left"><a href="/login/?loginas='. $Username .'" title="Login to this account">'. $Username .' <i class="fa fa-sign-in" style="color:green;"></i></a></td>
<td>'. $Domain . '</td>
<td>'. $Array['IP'] .'</td>
<td>'. $Array['RECORDS'] .'</td>
<td>'. $Array['SUSPENDED'] .'</td>
<td>'. $Array['DATE'] .'</td>
</tr>';
}
}
echo '</tbody>
</table>';
?>
</div>
<div id="MailDomains" class="tabcontent">
<?php
$Array = $Data = $tmpData = $AData = array();
foreach($UserData as $Username=>$Array)
{
$Data = shell_exec(VESTA_CMD.'v-list-mail-domains '. $Username .' json');
$tmpData[$Username] = json_decode($Data, true);
}
$Data = $tmpData;
ksort($Data);
echo '<table class="sortable responstable">
<thead>
<tr>
<th width="100">Username</th>
<th>Domain</th>
<th width="50">AntiSpam</th>
<th width="50">AntiVirus</th>
<th width="20">DKIM</th>
<th width="20">Accounts</th>
<th width="20">Catchall</th>
<th width="20">Disk Used</th>
<th width="50">Suspended</th>
<th width="70">Created</th>
</tr>
</thead>
<tbody>';
foreach($Data as $Username => $AData)
{
foreach($AData as $Domain => $Array)
{
echo '<tr>
<td align="left"><a href="/login/?loginas='. $Username .'" title="Login to this account">'. $Username .' <i class="fa fa-sign-in" style="color:green;"></i></a></td>
<td>'. $Domain . '</td>
<td>'. $Array['ANTISPAM'] .'</td>
<td>'. $Array['ANTIVIRUS'] .'</td>
<td>'. $Array['DKIM'] .'</td>
<td>'. $Array['ACCOUNTS'] .'</td>
<td>'. $Array['CATCHALL'] .'</td>
<td sorttable_customkey="'. $Array['U_DISKL'] .'">'. $Array['U_DISKL'] .'MB</td>
<td>'. $Array['SUSPENDED'] .'</td>
<td>'. $Array['DATE'] .'</td>
</tr>';
}
}
echo '</tbody>
</table>';
?>
</div>
<div id="CronJobs" class="tabcontent">
<?php
//$Users = shell_exec(VESTA_CMD.'v-list-users json');
//$Users = json_decode($Users, true);
$Array = $Data = $tmpData = $AData = array();
foreach($UserData as $Username=>$Array)
{
$Data = shell_exec(VESTA_CMD.'v-list-cron-jobs '. $Username .' json');
$tmpData[$Username] = json_decode($Data, true);
}
$Data = $tmpData;
ksort($Data);
echo '<table class="sortable responstable">
<thead>
<tr>
<th width="100">Username</th>
<th>Command</th>
<th class="sorttable_nosort" width="20">Min</th>
<th class="sorttable_nosort" width="20">Hour</th>
<th class="sorttable_nosort" width="20">Month</th>
<th class="sorttable_nosort" width="20">Day</th>
<th width="50">Suspended</th>
<th width="70">Created</th>
</tr>
</thead>
<tbody>';
foreach($Data as $Username => $AData)
{
foreach($AData as $Cron => $Array)
{
echo '<tr>
<td align="left"><a href="/login/?loginas='. $Username .'" title="Login to this account">'. $Username .' <i class="fa fa-sign-in" style="color:green;"></i></a></td>
<td>'. $Array['CMD'] . '</td>
<td>'. $Array['MIN'] .'</td>
<td>'. $Array['HOUR'] .'</td>
<td>'. $Array['MONTH'] .'</td>
<td>'. $Array['WDAY'] .'</td>
<td>'. $Array['SUSPENDED'] .'</td>
<td>'. $Array['DATE'] .'</td>
</tr>';
}
}
echo '</tbody>
</table>';
?>
</div>
<div id="LEUsers" class="tabcontent">
<?php
//$Users = shell_exec(VESTA_CMD.'v-list-users json');
//$Users = json_decode($Users, true);
$Array = $Data = $tmpData = $AData = array();
foreach($UserData as $Username=>$Array)
{
$Data = shell_exec(VESTA_CMD.'v-list-letsencrypt-user '. $Username .' json');
if(strstr($Data, 'Error')==TRUE)
continue;
$tmpData[$Username] = json_decode(str_replace('"THUMB', '"THUMB"', $Data), true)[$Username];
}
//print_r($tmpData);
$Data = $tmpData;
ksort($Data);
echo '<table class="sortable responstable">
<thead>
<tr>
<th width="100">Username</th>
<th>Assigned Email</th>
</tr>
</thead>
<tbody>';
foreach($Data as $Username => $Array)
{
//foreach($AData as $Cron => $Array)
//{
echo '<tr>
<td align="left"><a href="/login/?loginas='. $Username .'" title="Login to this account">'. $Username .' <i class="fa fa-sign-in" style="color:green;"></i></a></td>
<td>'. $Array['EMAIL'] . '</td>
</tr>';
//}
}
echo '</tbody>
</table>';
?>
</div>
</div>
<script src="https://www.kryogenix.org/code/browser/sorttable/sorttable.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
<script>
function doTab(evt, Tab) {
// Declare all variables
var i, tabcontent, tablinks;
evt.preventDefault();
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
// Show the current tab, and add an "active" class to the link that opened the tab
document.getElementById(Tab).style.display = "block";
evt.currentTarget.className += " active";
}
//$('ul.tab a:first-child').click();
</script>
<style>
<!--
/* Sortable tables */
table.sortable thead {
background-color:#eee;
color:#666666;
font-weight: bold;
cursor: default;
}
table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sorttable_nosort):after {
content: " \25B4\25BE"
}
.progress {
border: 1px solid #5d5d5d;
height: 10px;
width: 100px;
}
.progress .prgbar {
background: #ff8e61;
position: relative;
height: 10px;
z-index: 999;
}
/* Style the list */
ul.tab {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
/* Float the list items side by side */
ul.tab li {float: left;}
/* Style the links inside the list items */
ul.tab li a {
display: inline-block;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
transition: 0.3s;
font-size: 17px;
}
/* Change background color of links on hover */
ul.tab li a:hover {background-color: #ddd;}
/* Create an active/current tablink class */
ul.tab li a:focus, ul.tab li a.active {background-color: #ccc;}
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
.tabcontent {
-webkit-animation: fadeEffect 1s;
animation: fadeEffect 1s; /* Fading effect takes 1 second */
}
@-webkit-keyframes fadeEffect {
from {opacity: 0;}
to {opacity: 1;}
}
@keyframes fadeEffect {
from {opacity: 0;}
to {opacity: 1;}
}
.responstable {
margin: 1em 0;
width: 100%;
overflow: hidden;
background: #FFF;
color: #5d5d5d;
border-radius: 10px;
border: 1px solid #167F92;
font-size:12px;
}
.responstable tr {
border: 1px solid #D9E4E6;
}
.responstable tr:nth-child(odd) {
background-color: #efefef;
}
.responstable th {
display: none;
border: 1px solid #FFF;
background-color: #5d5d5d;
color: #FFF;
padding: 1em;
}
.responstable th:first-child {
display: table-cell;
}
.responstable th:nth-child(2) {
display: table-cell;
}
.responstable th:nth-child(2) span {
display: none;
}
.responstable th:nth-child(2):after {
content: attr(data-th);
}
@media (min-width: 480px) {
.responstable th:nth-child(2) span {
display: block;
}
.responstable th:nth-child(2):after {
display: none;
}
}
.responstable td {
display: block;
word-wrap: break-word;
max-width: 7em;
}
.responstable td:first-child {
display: table-cell;
border-right: 1px solid #D9E4E6;
}
@media (min-width: 480px) {
.responstable td {
border: 1px solid #D9E4E6;
}
}
.responstable th, .responstable td {
text-align: left;
margin: .5em 1em;
}
@media (min-width: 480px) {
.responstable th, .responstable td {
display: table-cell;
padding: 1em;
}
}
//-->
</style>
<div style="border:1px solid grey; padding:20px;text-align:center;">Made by <a href="https://blog.ss88.uk/vestacp-tools-plugin" target="_blank">Steven Sullivan</a> - Version 1.1</div>
<script>
window.onload = function(e){ document.getElementById("FirstTab").click() }
</script>
<?php
// Footer
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
?>