End Of Life - discontinue this branch!
[tomato.git] / release / src / router / www / vpn-pptp-online.asp
blobcf6b690bf67fd0b05be7c3fb82704d08a7383f6b
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato PPTPd GUI
4 Copyright (C) 2012 Augusto Bott
5 http://code.google.com/p/tomato-sdhc-vlan/
7 Tomato GUI
8 Copyright (C) 2006-2007 Jonathan Zarate
9 http://www.polarcloud.com/tomato/
10 For use with Tomato Firmware only.
11 No part of this file may be used without permission.
12 -->
13 <html>
14 <head>
15 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
16 <meta name='robots' content='noindex,nofollow'>
17 <title>[<% ident(); %>] VPN:PPTP Online</title>
18 <link rel='stylesheet' type='text/css' href='tomato.css'>
19 <% css(); %>
20 <script type='text/javascript' src='tomato.js'></script>
21 <style type='text/css'>
22 #dev-grid .co1 {
23 width: 10%;
25 #dev-grid .co2 {
26 width: 18%;
28 #dev-grid .co3 {
29 width: 12%;
31 #dev-grid .co4 {
32 width: 12%;
34 #dev-grid .co5 {
35 width: 18%;
37 #dev-grid .co6 {
38 width: 10%;
39 text-align: center;
41 #dev-grid .header {
42 text-align: left;
44 </style>
45 <script type='text/javascript'>
46 // <% nvram(''); %> // http_id
47 // <% pptpd_userol(); %>
49 list = [];
51 function find(pid) {
52 var e, i;
53 for (i = list.length - 1; i >= 0; --i) {
54 e = list[i];
55 if (e.pid == pid) {
56 return e;
59 return null;
62 function get(pid) {
63 var e, i;
64 if ((e = find(pid)) != null) {
65 return e;
67 e = {
68 pid: pid,
69 sourceip: '',
70 ip: '',
71 ifname: '',
72 username: '',
73 uptime: ''
75 list.push(e);
76 return e;
79 var xob = null;
80 function _disconnect(pid) {
81 form.submitHidden('/pptpd.cgi', { disconnect: pid });
84 function disconnect(a, pid) {
85 if (xob) return;
86 if ((xob = new XmlHttp()) == null) {
87 _disconnect(ip);
88 return;
90 a = E(a);
91 a.innerHTML = 'Disconnecting...';
93 xob.onCompleted = function(text, xml) {
94 a.innerHTML = '';
95 xob = null;
96 /* REMOVE-BEGIN */
97 // ref.refresh(text);
98 /* REMOVE-END */
99 if (!ref.running) {
100 setTimeout(
101 function() {
102 if (!ref.running) {
103 ref.once = 1;
104 ref.start();
106 }, 3000);
111 xob.onError = function() {
112 _disconnect(pid);
115 xob.post('/pptpd.cgi', 'disconnect=' + pid);
118 var ref = new TomatoRefresh('/update.cgi', 'exec=pptpd_userol', 0, 'pptpd_userol_refresh');
120 ref.refresh = function(text) {
121 eval(text);
122 dg.removeAllData();
123 dg.populate();
124 dg.resort();
127 var dg = new TomatoGrid();
129 dg.sortCompare = function(a, b) {
130 var col = this.sortColumn;
131 var ra = a.getRowData();
132 var rb = b.getRowData();
133 var r;
134 switch (col) {
135 case 3:
136 case 4:
137 r = cmpIP(ra.ip, rb.ip);
138 break;
139 default:
140 r = cmpText(a.cells[col].innerHTML, b.cells[col].innerHTML);
142 if (r == 0) {
143 r = cmpIP(ra.ip, rb.ip);
144 if (r == 0) r = cmpText(ra.ifname, rb.ifname);
146 return this.sortAscending ? r : -r;
149 dg.populate = function() {
150 var i, a, b, c, e;
151 var hangup;
152 list = [];
153 for (i = 0; i < list.length; ++i) {
154 list[i].pid = '';
155 list[i].ifname = '';
156 list[i].username = '';
157 list[i].uptime = '';
158 list[i].ip = '';
159 list[i].sourceip = '';
162 for (i = pptpd_online.length - 1; i >= 0; --i) {
163 a = pptpd_online[i];
164 e = get(a[0]);
165 e.ifname = a[1];
166 e.username = a[4];
167 e.ip = a[2];
168 e.sourceip = a[3];
169 e.uptime = a[5];
172 for (i = list.length - 1; i >= 0; --i) {
173 e = list[i];
174 hangup = '<div id="div_'+e.pid+'"><a href="javascript:disconnect(\'div_'+e.pid + '\',' + e.pid + ')" title="Disconnect" id="pid_' + e.pid + '">Disconnect</a></div>';
175 /* REMOVE-BEGIN */
176 // this.insert(-1, e, [
177 // e.ifname, e.username, e.uptime, e.ip, e.sourceip, hangup], false);
178 /* REMOVE-END */
179 dg.insertData(-1, [ e.ifname, e.username, e.uptime, e.ip, e.sourceip, hangup ]);
183 dg.setup = function() {
184 this.init('dev-grid', 'sort');
185 this.headerSet(['Interface', 'Username', 'Online Since', 'VPN IP Address', 'Source IP Address', 'Action']);
186 this.populate();
187 this.sort(1);
190 function dateTimeString(timestamp) {
191 var x = new Date(timestamp*1000);
192 var year = x.getFullYear();
193 var month = (x.getMonth() + 1).pad(2);
194 var day = (x.getDate()).pad(2);
195 var time = timeString((x.getHours() * 60) + x.getMinutes());
196 return (year + '-' + month + '-' + day + ' ' + time);
199 dg.dataToView = function(data) {
200 var l;
201 if (data[2] < 946684800) {
202 l = 'Not Available';
203 } else {
204 /* REMOVE-BEGIN */
205 // l = new Date(data[2] *1000);
206 // l = l.toDateString() + ' ' + l.toTimeString();
207 /* REMOVE-END */
208 l = dateTimeString(data[2]);
210 return [data[0],
211 data[1],
213 data[3],
214 data[4],
215 data[5]];
218 function earlyInit() {
219 dg.setup();
222 function init() {
223 dg.recolor();
224 ref.initPage(3000, 3);
226 </script>
227 </head>
228 <body onload='init()'>
229 <table id='container' cellspacing=0>
230 <tr><td colspan=2 id='header'>
231 <div class='title'>Tomato</div>
232 <div class='version'>Version <% version(); %></div>
233 </td></tr>
234 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
235 <td id='content'>
236 <div id='ident'><% ident(); %></div>
237 <div class='section-title'>PPTP Users Online</div>
238 <div class='section'>
239 <table id='dev-grid' class='tomato-grid' cellspacing=0></table>
240 </div>
241 <div style="float:right;text-align:right">
242 &raquo; <a href="vpn-pptp-server.asp">Configure</a>
243 </div>
244 </td></tr>
245 <tr><td id='footer' colspan=2><script type='text/javascript'>genStdRefresh(1,1,'ref.toggle()');</script></td></tr>
246 </table>
247 <script type='text/javascript'>earlyInit();</script>
248 </body>
249 </html>