1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
6 For use with Tomato Firmware only.
7 No part of this file may be used without permission.
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>
19 <style tyle='text/css'
>
23 #ss-grid .co1, #ss-grid .co2, #ss-grid .co3 {
33 <style type='text/css'
>
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;
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
)
83 f
= fields
.getAll(row
);
85 s
= f
[0].value
.trim().replace(/\s+/g, ' ');
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
);
91 if (this.existName(s
)) {
92 ferror
.set(f
[0], 'Duplicate share name.', quiet
);
98 ferror
.set(f
[0], 'Empty share name is not allowed.', quiet
);
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;
108 ssg
.resetNewEditor = function()
112 f
= fields
.getAll(this.newEditor
);
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('<');
137 this.insertData(-1, t
);
142 this.showNewEditor();
143 this.resetNewEditor();
146 function verifyFields(focused
, quiet
)
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;
164 if (!v_length('_smbd_user', quiet
, 1)) return 0;
165 if (!v_length('_smbd_passwd', quiet
, 1)) return 0;
168 if (b
.value
== 'root') {
169 ferror
.set(b
, 'User Name \"root\" is not allowed.', quiet
);
180 if (ssg
.isEditing()) return;
181 if (!verifyFields(null, 0)) return;
185 var data
= ssg
.getAllData();
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;
193 fom
.smbd_wins
.value
= nvram
.smbd_wins
;
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>
207 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
209 <div id='ident'
><%
ident(); %></div>
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
},
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)']
237 ,['932', '932 (Japanese)'],['936', '936 (Simplified Chinese)'],['949', '949 (Korean)'],['950', '950 (Traditional Chinese / Big5)']
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
: ' Master Browser ', name
: 'f_smbd_master', type
: 'checkbox', value
: nvram
.smbd_master
== 1 },
248 { suffix
: ' WINS Server ', name
: 'f_smbd_wins', type
: 'checkbox', value
: (nvram
.smbd_wins
== 1) && (nvram
.wan_wins
== '' || nvram
.wan_wins
== '0.0.0.0') }
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>
260 <small>When no shares are specified and auto-sharing is disabled,
<i>/mnt
</i> directory is shared in Read Only mode.
</small>
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();'
>
273 <script type='text/javascript'
>verifyFields(null, 1);</script>