forked from Jackysi/advancedtomato-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools-shell.asp
129 lines (107 loc) · 3.6 KB
/
tools-shell.asp
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
<!--
Tomato GUI
For use with Tomato Firmware only.
No part of this file may be used without permission.
--><title>System Commands</title>
<content>
<style>
.sectionshell { margin-top: 10px; }
textarea { width: 80%; height: 35px; }
table tr td:first-child { width: 150px; }
pre { max-height: 400px; overflow: auto; }
</style>
<script type="text/javascript">
var cmdresult = '';
var cmd = null;
var ref = new TomatoRefresh('/update.cgi', '', 0, 'tools-shell_refresh');
ref.refresh = function(text)
{
execute();
}
function verifyFields(focused, quiet)
{
return 1;
}
function escapeText(s)
{
function esc(c) {
return '&#' + c.charCodeAt(0) + ';';
}
return s.replace(/[&"'<>]/g, esc).replace(/\n/g, ' <br>').replace(/ /g, ' ');
}
function spin(x)
{
E('execb').disabled = x;
E('_f_cmd').disabled = x;
E('wait').style.visibility = x ? 'visible' : 'hidden';
if (!x) cmd = null;
}
function updateResult()
{
E('result').innerHTML = '<tt>' + escapeText(cmdresult) + '</tt>';
cmdresult = '';
spin(0);
}
function execute()
{
// Opera 8 sometimes sends 2 clicks
if (cmd) return;
spin(1);
cmd = new XmlHttp();
cmd.onCompleted = function(text, xml) {
eval(text);
updateResult();
}
cmd.onError = function(x) {
cmdresult = 'ERROR: ' + x;
updateResult();
}
var s = E('_f_cmd').value;
cmd.post('shell.cgi', 'action=execute&command=' + escapeCGI(s.replace(/\r/g, '')));
cookie.set('shellcmd', escape(s));
}
function init()
{
var s;
if ((s = cookie.get('shellcmd')) != null) E('_f_cmd').value = unescape(s);
if (((s = cookie.get('tools_shell_notes_vis')) != null) && (s == '1')) {
toggleVisibility("notes");
}
$('#refresh').append(genStdRefresh(1,1,"ref.toggle()"));
}
function toggleVisibility(whichone) {
if (E('sesdiv_' + whichone).style.display == '') {
E('sesdiv_' + whichone).style.display = 'none';
E('sesdiv_' + whichone + '_showhide').innerHTML = '<i class="icon-chevron-up"></i>';
cookie.set('status_overview_' + whichone + '_vis', 0);
} else {
E('sesdiv_' + whichone).style.display='';
E('sesdiv_' + whichone + '_showhide').innerHTML = '<i class="icon-chevron-down"></i>';
cookie.set('status_overview_' + whichone + '_vis', 1);
}
}
</script>
<ul class="nav-tabs">
<li><a class="ajaxload" href="tools-ping.asp"><i class="icon-ping"></i> Ping</a></li>
<li><a class="ajaxload" href="tools-trace.asp"><i class="icon-gauge"></i> Trace</a></li>
<li><a class="active"><i class="icon-cmd"></i> System Commands</a></li>
<li><a class="ajaxload" href="tools-survey.asp"><i class="icon-signal"></i> Wireless Survey</a></li>
<li><a class="ajaxload" href="tools-wol.asp"><i class="icon-forward"></i> WOL</a></li>
</ul>
<div class="box">
<div class="heading">System Shell</div>
<div class="content">
<div id="command-form"></div><hr>
<div style="visibility:hidden;" id="wait">Please wait... <span class="spinner"></span></div>
<pre id="result"></pre>
<script type="text/javascript">
$('#command-form').forms([
{ title: 'Command', help:'Use the command "nvram export --set" or "nvram export --set | grep qos" to cut and paste configuration',
name: 'f_cmd', type: 'textarea', wrap: 'off', value: '', style: 'width: 100%; height: 80px;' }
], { grid: ['col-sm-2', 'col-sm-10'] });
</script>
</div>
</div>
<div id="refresh"></div><button type="button" value="Execute" onclick="execute()" id="execb" class="btn">Execute <i class="icon-cmd"></i></button>
<script type="text/javascript">init();</script>
</content>