mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-03 08:33:56 +08:00
update 2026-05-10 09:48:30
This commit is contained in:
1 parent
95ac96413e
commit
0b362674f1
6244 files changed
+2992248
No files matched your search
@@ -0,0 +1,34 @@
|
||||
<html><head><title>Traffic</title>
|
||||
<script type="text/javascript">
|
||||
function getSize(size) {
|
||||
if (size === 0) return '0 ';
|
||||
var prefix=["","k","M","G","T","P","E","Z"];
|
||||
var base=1024, precision = 1;
|
||||
var pos=Math.floor(Math.log(size)/Math.log(base));
|
||||
if (pos > 2) precision=100;
|
||||
return (Math.round(size/Math.pow(base,pos)*precision)/precision)+' '+prefix[pos];
|
||||
}
|
||||
function padstr(str) {
|
||||
return str < 10 ? '0' + str : str;
|
||||
}
|
||||
function dateToString(date) {
|
||||
var d = new Date((/\W/g).test(date) ? date : date * 1000);
|
||||
var Y = d.getFullYear(), M = d.getMonth(), D = d.getDate();
|
||||
var hh = d.getHours(), mm = d.getMinutes(), ss = d.getSeconds();
|
||||
return Y + '/' + padstr(M) + '/' + padstr(D) + ' ' + padstr(hh) + ':' + padstr(mm) + ':' + padstr(ss);
|
||||
}
|
||||
</script></head>
|
||||
<body><h1>Total Usage:</h1>
|
||||
<table border="1">
|
||||
<tr bgcolor=silver>
|
||||
<th>User</th>
|
||||
<th>Down Speed</th>
|
||||
<th>Up Speed</th>
|
||||
<th>Download</th>
|
||||
<th>Upload</th>
|
||||
<th>Total</th>
|
||||
<th>First seen</th>
|
||||
<th>Last seen</th>
|
||||
</tr>
|
||||
<script type="text/javascript">
|
||||
var values = new Array(
|
||||
@@ -0,0 +1,18 @@
|
||||
var speedIn = 0;
|
||||
var speedOut = 0;
|
||||
var totalIn = 0;
|
||||
var totalOut = 0;
|
||||
for (i=0; i < values.length-1; i++) {
|
||||
speedIn += values[i][3];
|
||||
speedOut += values[i][4]
|
||||
totalIn += values[i][5];
|
||||
totalOut += values[i][6];
|
||||
document.write("<tr><td><div title=\"" + values[i][1] + " (" + values[i][2] + ")" + "\">" + values[i][0] + "</div></td>");
|
||||
for (j=3; j < 8; j++)
|
||||
document.write("<td>" + getSize(values[i][j]) + ((j == 3) || (j ==4) ? 'B/s' : 'B') + "</td>");
|
||||
document.write("<td>" + dateToString(values[i][8]) + "</td><td>" + dateToString(values[i][9]) + "</td></tr>");
|
||||
}
|
||||
document.write("<tr><td>TOTAL</td><td>" + getSize(speedIn) + "B/s" + "</td><td>" + getSize(speedOut) + "B/s" + "</td><td>" + getSize(totalIn) + "</td><td>" + getSize(totalOut) + "</td><td>" + getSize(totalIn + totalOut) + "</td><td></td><td></td></tr>");
|
||||
</script></table>
|
||||
<br /><small>This page was generated on (date)</small>
|
||||
</body></html>
|
||||
Reference in new issue
Block a user