usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / www / nas-samba.asp
blob3e8ba1a8dedbc0637ec5cb398745efac1789d3f3
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Samba Server - !!TB
6 For use with Tomato Firmware only.
7 No part of this file may be used without permission.
8 -->
9 <html>
10 <head>
11 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
12 <meta name='robots' content='noindex,nofollow'>
13 <title>[<% ident(); %>] NAS: File Sharing</title>
14 <link rel='stylesheet' type='text/css' href='tomato.css'>
15 <link rel='stylesheet' type='text/css' href='color.css'>
16 <script type='text/javascript' src='tomato.js'></script>
18 <!-- / / / -->
19 <style tyle='text/css'>
20 #ss-grid {
21 width: 99%;
23 #ss-grid .co1, #ss-grid .co2, #ss-grid .co3 {
24 width: 25%;
26 #ss-grid .co4 {
27 width: 16%;
29 #ss-grid .co5 {
30 width: 9%;
32 </style>
33 <style type='text/css'>
34 textarea {
35 width: 98%;
36 height: 6em;
38 </style>
40 <script type='text/javascript' src='debug.js'></script>
42 <script type='text/javascript'>
44 // <% nvram("smbd_enable,smbd_user,smbd_passwd,smbd_wgroup,smbd_cpage,smbd_custom,smbd_master,smbd_wins,smbd_shares,smbd_autoshare,wan_wins"); %>
46 var ssg = new TomatoGrid();
48 ssg.exist = function(f, v)
50 var data = this.getAllData();
51 for (var i = 0; i < data.length; ++i) {
52 if (data[i][f] == v) return true;
54 return false;
57 ssg.existName = function(name)
59 return this.exist(0, name);
62 ssg.sortCompare = function(a, b) {
63 var col = this.sortColumn;
64 var da = a.getRowData();
65 var db = b.getRowData();
66 var r = cmpText(da[col], db[col]);
67 return this.sortAscending ? r : -r;
70 ssg.dataToView = function(data) {
71 return [data[0], data[1], data[2], ['Read Only', 'Read / Write'][data[3]], ['No', 'Yes'][data[4]]];
74 ssg.fieldValuesToData = function(row) {
75 var f = fields.getAll(row);
76 return [f[0].value, f[1].value, f[2].value, f[3].value, f[4].value];
79 ssg.verifyFields = function(row, quiet)
81 var f, s;
83 f = fields.getAll(row);
85 s = f[0].value.trim().replace(/\s+/g, ' ');
86 if (s.length > 0) {
87 if (s.search(/^[ a-zA-Z0-9_\-\$]+$/) == -1) {
88 ferror.set(f[0], 'Invalid share name. Only characters "$ A-Z 0-9 - _" and spaces are allowed.', quiet);
89 return 0;
91 if (this.existName(s)) {
92 ferror.set(f[0], 'Duplicate share name.', quiet);
93 return 0;
95 f[0].value = s;
97 else {
98 ferror.set(f[0], 'Empty share name is not allowed.', quiet);
99 return 0;
102 if (!v_nodelim(f[1], quiet, 'Directory', 1) || !v_path(f[1], quiet, 1)) return 0;
103 if (!v_nodelim(f[2], quiet, 'Description', 1)) return 0;
105 return 1;
108 ssg.resetNewEditor = function()
110 var f;
112 f = fields.getAll(this.newEditor);
113 ferror.clearAll(f);
115 f[0].value = '';
116 f[1].value = '';
117 f[2].value = '';
118 f[3].selectedIndex = 0;
119 f[4].selectedIndex = 0;
122 ssg.setup = function()
124 this.init('ss-grid', 'sort', 50, [
125 { type: 'text', maxlen: 32 },
126 { type: 'text', maxlen: 256 },
127 { type: 'text', maxlen: 64 },
128 { type: 'select', options: [[0, 'Read Only'],[1, 'Read / Write']] },
129 { type: 'select', options: [[0, 'No'],[1, 'Yes']] }
131 this.headerSet(['Share Name', 'Directory', 'Description', 'Access Level', 'Hidden']);
133 var s = nvram.smbd_shares.split('>');
134 for (var i = 0; i < s.length; ++i) {
135 var t = s[i].split('<');
136 if (t.length == 5) {
137 this.insertData(-1, t);
141 this.sort(0);
142 this.showNewEditor();
143 this.resetNewEditor();
146 function verifyFields(focused, quiet)
148 var a, b;
150 a = E('_smbd_enable').value;
152 elem.display(PR('_smbd_user'), PR('_smbd_passwd'), (a == 2));
154 E('_smbd_wgroup').disabled = (a == 0);
155 E('_smbd_cpage').disabled = (a == 0);
156 E('_smbd_custom').disabled = (a == 0);
157 E('_smbd_autoshare').disabled = (a == 0);
158 E('_f_smbd_master').disabled = (a == 0);
159 E('_f_smbd_wins').disabled = (a == 0 || (nvram.wan_wins != '' && nvram.wan_wins != '0.0.0.0'));
161 if (a != 0 && !v_length('_smbd_custom', quiet, 0, 2048)) return 0;
163 if (a == 2) {
164 if (!v_length('_smbd_user', quiet, 1)) return 0;
165 if (!v_length('_smbd_passwd', quiet, 1)) return 0;
167 b = E('_smbd_user');
168 if (b.value == 'root') {
169 ferror.set(b, 'User Name \"root\" is not allowed.', quiet);
170 return 0;
172 ferror.clear(b);
175 return 1;
178 function save()
180 if (ssg.isEditing()) return;
181 if (!verifyFields(null, 0)) return;
183 var fom = E('_fom');
185 var data = ssg.getAllData();
186 var r = [];
187 for (var i = 0; i < data.length; ++i) r.push(data[i].join('<'));
188 fom.smbd_shares.value = r.join('>');
189 fom.smbd_master.value = E('_f_smbd_master').checked ? 1 : 0;
190 if (nvram.wan_wins == '' || nvram.wan_wins == '0.0.0.0')
191 fom.smbd_wins.value = E('_f_smbd_wins').checked ? 1 : 0;
192 else
193 fom.smbd_wins.value = nvram.smbd_wins;
195 form.submit(fom, 1);
197 </script>
199 </head>
200 <body>
201 <form id='_fom' method='post' action='tomato.cgi'>
202 <table id='container' cellspacing=0>
203 <tr><td colspan=2 id='header'>
204 <div class='title'>Tomato</div>
205 <div class='version'>Version <% version(); %></div>
206 </td></tr>
207 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
208 <td id='content'>
209 <div id='ident'><% ident(); %></div>
211 <!-- / / / -->
213 <input type='hidden' name='_nextpage' value='nas-samba.asp'>
214 <input type='hidden' name='_service' value='samba-restart'>
216 <input type='hidden' name='smbd_master'>
217 <input type='hidden' name='smbd_wins'>
218 <input type='hidden' name='smbd_shares'>
220 <div class='section-title'>Samba File Sharing</div>
221 <div class='section'>
222 <script type='text/javascript'>
223 createFieldTable('', [
224 { title: 'Enable File Sharing', name: 'smbd_enable', type: 'select',
225 options: [['0', 'No'],['1', 'Yes, no Authentication'],['2', 'Yes, Authentication required']],
226 value: nvram.smbd_enable },
227 { title: 'User Name', indent: 2, name: 'smbd_user', type: 'text', maxlen: 50, size: 32,
228 value: nvram.smbd_user },
229 { title: 'Password', indent: 2, name: 'smbd_passwd', type: 'password', maxlen: 50, size: 32, peekaboo: 1,
230 value: nvram.smbd_passwd },
231 null,
232 { title: 'Workgroup Name', name: 'smbd_wgroup', type: 'text', maxlen: 20, size: 32,
233 value: nvram.smbd_wgroup },
234 { title: 'Client Codepage', name: 'smbd_cpage', type: 'select',
235 options: [['', 'Unspecified'],['437', '437 (United States, Canada)'],['850', '850 (Western Europe)'],['852', '852 (Central / Eastern Europe)'],['866', '866 (Cyrillic / Russian)']
236 /* LINUX26-BEGIN */
237 ,['932', '932 (Japanese)'],['936', '936 (Simplified Chinese)'],['949', '949 (Korean)'],['950', '950 (Traditional Chinese / Big5)']
238 /* LINUX26-END */
240 suffix: ' <small> (start cmd.exe and type chcp to see the current code page)</small>',
241 value: nvram.smbd_cpage },
242 { title: 'Samba<br>Custom Configuration', name: 'smbd_custom', type: 'textarea', value: nvram.smbd_custom },
243 { title: 'Auto-share all USB Partitions', name: 'smbd_autoshare', type: 'select',
244 options: [['0', 'Disabled'],['1', 'Read Only'],['2', 'Read / Write'],['3', 'Hidden Read / Write']],
245 value: nvram.smbd_autoshare },
246 { title: 'Options', multi: [
247 { suffix: '&nbsp; Master Browser &nbsp;&nbsp;&nbsp;', name: 'f_smbd_master', type: 'checkbox', value: nvram.smbd_master == 1 },
248 { suffix: '&nbsp; WINS Server (if not defined on Basic/Network page) &nbsp;', name: 'f_smbd_wins', type: 'checkbox', value: (nvram.smbd_wins == 1) && (nvram.wan_wins == '' || nvram.wan_wins == '0.0.0.0') }
251 </script>
252 </div>
253 <br>
255 <div class='section-title'>Additional Shares List</div>
256 <div class='section'>
257 <table class='tomato-grid' cellspacing=1 id='ss-grid'></table>
258 <script type='text/javascript'>ssg.setup();</script>
259 <br>
260 <small>When no shares are specified and auto-sharing is disabled, <i>/mnt</i> directory is shared in Read Only mode.</small>
261 </div>
263 <!-- / / / -->
265 </td></tr>
266 <tr><td id='footer' colspan=2>
267 <span id='footer-msg'></span>
268 <input type='button' value='Save' id='save-button' onclick='save()'>
269 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'>
270 </td></tr>
271 </table>
272 </form>
273 <script type='text/javascript'>verifyFields(null, 1);</script>
274 </body>
275 </html>