Set version to "2.7".
[ipfire-2.x.git] / html / cgi-bin / samba.cgi
CommitLineData
5e773594 1#!/usr/bin/perl
70df8302
MT
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
5e773594
MT
21
22use strict;
23# enable only the following on debugging purpose
cb5e9c6c
CS
24#use warnings;
25#use CGI::Carp 'fatalsToBrowser';
5e773594
MT
26
27require '/var/ipfire/general-functions.pl';
28require "${General::swroot}/lang.pl";
29require "${General::swroot}/header.pl";
30
31my %sambasettings = ();
44254afd 32my %cgisettings = ();
5e773594
MT
33my %checked = ();
34my %netsettings = ();
97de2cae 35my %ovpnsettings = ();
f2fdd0c1
CS
36my %color = ();
37my %mainsettings = ();
5e773594
MT
38my $message = "";
39my $errormessage = "";
c41c2eb4 40
fa7be659 41my @Logs = qx(ls /var/log/samba/);
c9e1c143 42my $Log =$Lang::tr{'no log selected'};
c41c2eb4
CS
43
44my $Status = qx(/usr/local/bin/sambactrl smbstatus);
45$Status=~s/\n/<br \/>/g;
46
1ee8bf5d
MT
47my $userentry = "";
48my @user = ();
49my @userline = ();
c41c2eb4 50my $userfile = "${General::swroot}/samba/private/smbpasswd";
5e773594 51my %selected= () ;
c41c2eb4
CS
52
53my $defaultoption= "[Share]\npath = /var/ipfire/samba/share1\ncomment = Share - Public Access\nbrowseable = yes\nwriteable = yes\ncreate mask = 0777\ndirectory mask = 0777\npublic = yes\nforce user = samba";
54my $defaultprinter= "[Printer]\ncomment = Printer public\npath = /var/spool/cups\nprinting = sysvn\nprintcap = lpstat\npublic = yes\nwritable = no\nprintable = yes";
55my %printer = ();
56my %shares = ();
57
5e773594 58&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
97de2cae 59&General::readhash("${General::swroot}/ovpn/settings", \%ovpnsettings);
f2fdd0c1
CS
60&General::readhash("${General::swroot}/main/settings", \%mainsettings);
61&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
5e773594 62
f57976de
CS
63my @ovpnnetwork = split(/\//,$ovpnsettings{'DOVPN_SUBNET'});
64my @ovpnip = split(/\./,$ovpnnetwork[0]);
65$ovpnip[3]=$ovpnip[3]+1;
66
14cc7eac 67############################################################################################################################
32f77a0b 68############################################# Samba Dienste fr Statusberprfung ##########################################
14cc7eac 69
c41c2eb4
CS
70my %servicenames = ('SMB Daemon' => 'smbd','NetBIOS Nameserver' => 'nmbd');
71#my %servicenames = ('SMB Daemon' => 'smbd','NetBIOS Nameserver' => 'nmbd','Winbind Daemon' => 'winbindd');
5e773594
MT
72
73&Header::showhttpheaders();
74
14cc7eac 75############################################################################################################################
32f77a0b 76#################################### Initialisierung von Samba Variablen fr global Settings ###############################
14cc7eac 77
5e773594 78$sambasettings{'WORKGRP'} = 'homeip.net';
fa7be659 79$sambasettings{'NETBIOSNAME'} = 'IPFire';
4594712a 80$sambasettings{'SRVSTRING'} = 'Samba running on IPFire 2.7';
1ee8bf5d 81$sambasettings{'INTERFACES'} = '';
5e773594 82$sambasettings{'SECURITY'} = 'share';
c41c2eb4 83$sambasettings{'OSLEVEL'} = '33';
97de2cae
MT
84$sambasettings{'GREEN'} = 'on';
85$sambasettings{'BLUE'} = 'off';
86$sambasettings{'ORANGE'} = 'off';
87$sambasettings{'VPN'} = 'off';
fa7be659
CS
88$sambasettings{'WINSSRV'} = '';
89$sambasettings{'WINSSUPPORT'} = 'on';
90$sambasettings{'REMOTEANNOUNCE'} = '';
2a1f6aa7 91$sambasettings{'REMOTESYNC'} = '';
32f77a0b 92$sambasettings{'PASSWORDSYNC'} = 'off';
c9e1c143 93$sambasettings{'OTHERINTERFACES'} = '127.0.0.1';
1ee8bf5d
MT
94$sambasettings{'GUESTACCOUNT'} = 'samba';
95$sambasettings{'MAPTOGUEST'} = 'Never';
c9e1c143 96$sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 winbind:2';
97e7cfaf
CS
97$sambasettings{'SYSLOGLEVEL'} = '1';
98$sambasettings{'SYSLOGONLY'} = 'on';
5595bc03
CS
99$sambasettings{'DOSCHARSET'} = 'CP850';
100$sambasettings{'UNIXCHARSET'} = 'UTF8';
101$sambasettings{'DISPLAYCHARSET'} = 'CP850';
88932936 102$sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 SO_KEEPALIVE';
c9f3d846
AF
103$sambasettings{'WIDELINKS'} = 'on';
104$sambasettings{'UNIXEXTENSION'} = 'off';
5e773594 105### Values that have to be initialized
fa7be659 106$sambasettings{'ACTION'} = '';
c41c2eb4
CS
107### Samba CUPS Variablen
108$sambasettings{'LOADPRINTERS'} = 'Yes';
109$sambasettings{'PRINTING'} = 'cups';
110$sambasettings{'PRINTCAPNAME'} = 'cups';
c9e1c143 111my $LOGLINES = '50';
5e773594 112
32f77a0b
CS
113################################################## Samba PDC Variablen #####################################################
114
115$sambasettings{'LOCALMASTER'} = 'off';
116$sambasettings{'DOMAINMASTER'} = 'off';
117$sambasettings{'PREFERREDMASTER'} = 'off';
118my $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`;
119
120
121############################################################################################################################
122
5e773594
MT
123&General::readhash("${General::swroot}/samba/settings", \%sambasettings);
124&Header::getcgihash(\%sambasettings);
125
69addbb8 126sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();}
63d4db83 127
c9f3d846 128if (($sambasettings{'WIDELINKS'} eq 'on') & ($sambasettings{'UNIXEXTENSION'} eq 'on'))
82f53e0a 129 {$errormessage = "$errormessage<br />Don't enable 'Wide links' and 'Unix extension' at the same time"; }
c9f3d846 130
5e773594
MT
131&Header::openpage('Samba', 1, '');
132&Header::openbigbox('100%', 'left', '', $errormessage);
133
134############################################################################################################################
fa7be659 135############################################# Samba Rootskript aufrufe fr SU-Actions #######################################
14cc7eac 136
63d4db83
CS
137if ($sambasettings{'ACTION'} eq 'smbuserdisable'){system("/usr/local/bin/sambactrl smbuserdisable $sambasettings{'NAME'}");refreshpage();}
138if ($sambasettings{'ACTION'} eq 'smbuserenable'){system("/usr/local/bin/sambactrl smbuserenable $sambasettings{'NAME'}");refreshpage();}
139if ($sambasettings{'ACTION'} eq 'smbuseradd'){system("/usr/local/bin/sambactrl smbuseradd $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");refreshpage();}
140if ($sambasettings{'ACTION'} eq 'smbpcadd'){system("/usr/local/bin/sambactrl smbpcadd $sambasettings{'PCNAME'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");refreshpage();}
141if ($sambasettings{'ACTION'} eq 'smbchangepw'){system("/usr/local/bin/sambactrl smbchangepw $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'}");refreshpage();}
142if ($sambasettings{'ACTION'} eq 'smbrestart'){system("/usr/local/bin/sambactrl smbrestart");refreshpage();}
143if ($sambasettings{'ACTION'} eq 'smbstart'){system("/usr/local/bin/sambactrl smbstart");refreshpage();}
144if ($sambasettings{'ACTION'} eq 'smbstop'){system("/usr/local/bin/sambactrl smbstop");refreshpage();}
145if ($sambasettings{'ACTION'} eq 'smbreload'){system("/usr/local/bin/sambactrl smbreload");refreshpage();}
fa7be659
CS
146if ($sambasettings{'ACTION'} eq 'globalresetyes')
147 {
148 system("/usr/local/bin/sambactrl smbglobalreset");
149 $sambasettings{'WORKGRP'} = 'homeip.net';
150 $sambasettings{'NETBIOSNAME'} = 'IPFire';
151 $sambasettings{'SRVSTRING'} = 'Samba running on IPFire 2.0';
152 $sambasettings{'INTERFACES'} = '';
153 $sambasettings{'SECURITY'} = 'share';
154 $sambasettings{'OSLEVEL'} = '65';
155 $sambasettings{'GREEN'} = 'on';
156 $sambasettings{'BLUE'} = 'off';
157 $sambasettings{'ORANGE'} = 'off';
158 $sambasettings{'VPN'} = 'off';
159 $sambasettings{'WINSSRV'} = '';
160 $sambasettings{'WINSSUPPORT'} = 'on';
161 $sambasettings{'REMOTEANNOUNCE'} = '';
2a1f6aa7 162 $sambasettings{'REMOTESYNC'} = '';
fa7be659 163 $sambasettings{'PASSWORDSYNC'} = 'off';
c9e1c143 164 $sambasettings{'OTHERINTERFACES'} = '127.0.0.1';
fa7be659
CS
165 $sambasettings{'GUESTACCOUNT'} = 'samba';
166 $sambasettings{'MAPTOGUEST'} = 'Never';
c9e1c143 167 $sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 winbind:2';
97e7cfaf
CS
168 $sambasettings{'SYSLOGLEVEL'} = '1';
169 $sambasettings{'SYSLOGONLY'} = 'on';
5595bc03
CS
170 $sambasettings{'DOSCHARSET'} = 'CP850';
171 $sambasettings{'UNIXCHARSET'} = 'UTF8';
172 $sambasettings{'DISPLAYCHARSET'} = 'CP850';
c41c2eb4
CS
173### Samba CUPS Variablen
174 $sambasettings{'LOADPRINTERS'} = 'Yes';
175 $sambasettings{'PRINTING'} = 'cups';
176 $sambasettings{'PRINTCAPNAME'} = 'cups';
177 $sambasettings{'PRINTERNAME'} = 'Printer';
fa7be659 178### Values that have to be initialized
c9f3d846
AF
179 $sambasettings{'WIDELINKS'} = 'on';
180 $sambasettings{'UNIXEXTENSION'} = 'off';
fa7be659
CS
181 $sambasettings{'ACTION'} = '';
182 $sambasettings{'LOCALMASTER'} = 'off';
183 $sambasettings{'DOMAINMASTER'} = 'off';
184 $sambasettings{'PREFERREDMASTER'} = 'off';
88932936 185 $sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 SO_KEEPALIVE';
fa7be659 186 $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`;
60124059 187 system("/usr/local/bin/sambactrl smbreload");
63d4db83 188 refreshpage();
fa7be659 189 }
44254afd 190
32f77a0b 191############################################################################################################################
fa7be659 192################################################ Sicherheitsabfrage für den Reset ##########################################
32f77a0b 193
fa7be659
CS
194if ($sambasettings{'ACTION'} eq 'globalreset')
195 {
196 print <<END
92004c61 197 <br />
fa7be659 198 <table width='95%' cellspacing='0'>
f2fdd0c1 199 <tr><td bgcolor='$color{'color20'}' colspan='3' align='center'><b>$Lang::tr{'resetglobals'}</b>
fa7be659 200 <tr><td align='right' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
a08a5f33 201 $Lang::tr{'yes'} <input type='image' alt='$Lang::tr{'yes'}' title='$Lang::tr{'yes'}' src='/images/edit-redo.png' />
fa7be659
CS
202 <input type='hidden' name='ACTION' value='globalresetyes' /></form></td>
203 <td align='left' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
a08a5f33 204 <input type='image' alt='$Lang::tr{'no'}' title='$Lang::tr{'no'}' src='/images/dialog-error.png' /> $Lang::tr{'no'}
fa7be659
CS
205 <input type='hidden' name='ACTION' value='cancel' /></form></td>
206 </tr>
207 </table>
208END
209;
32f77a0b
CS
210}
211
fa7be659
CS
212if ($sambasettings{'ACTION'} eq 'sharesreset')
213 {
214 print <<END
92004c61 215 <br />
fa7be659 216 <table width='95%' cellspacing='0'>
f2fdd0c1 217 <tr><td bgcolor='$color{'color20'}' colspan='3' align='center'><b>$Lang::tr{'resetshares'}</b>
fa7be659 218 <tr><td align='right' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
a08a5f33 219 $Lang::tr{'yes'} <input type='image' alt='$Lang::tr{'yes'}' title='$Lang::tr{'yes'}' src='/images/edit-redo.png' />
fa7be659
CS
220 <input type='hidden' name='ACTION' value='sharesresetyes' /></form></td>
221 <td align='left' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
a08a5f33 222 <input type='image' alt='$Lang::tr{'no'}' title='$Lang::tr{'no'}' src='/images/dialog-error.png' /> $Lang::tr{'no'}
fa7be659
CS
223 <input type='hidden' name='ACTION' value='cancel' /></form></td>
224 </tr>
225 </table>
226END
227;
228 }
229
230############################################################################################################################
231########################################### Samba Benutzer oder PC l�chen #################################################
232
63d4db83 233if ($sambasettings{'ACTION'} eq 'userdelete'){system("/usr/local/bin/sambactrl smbuserdelete $sambasettings{'NAME'}");refreshpage();}
fa7be659 234
14cc7eac
MT
235############################################################################################################################
236##################################### Umsetzen der Werte von Checkboxen und Dropdowns ######################################
1ee8bf5d
MT
237
238if ($sambasettings{'ACTION'} eq $Lang::tr{'save'})
239{
240$sambasettings{'INTERFACES'} = '';
44254afd
MT
241if ($sambasettings{'GREEN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'GREEN_DEV'}";}
242if ($sambasettings{'BLUE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'BLUE_DEV'}";}
243if ($sambasettings{'ORANGE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'ORANGE_DEV'}";}
f57976de 244if ($sambasettings{'VPN'} eq 'on'){$sambasettings{'INTERFACES'} .= " ";}
44254afd 245if ($sambasettings{'OTHERINTERFACES'} ne ''){ $sambasettings{'INTERFACES'} .= " $sambasettings{'OTHERINTERFACES'}";}
1ee8bf5d
MT
246
247############################################################################################################################
32f77a0b 248##################################### Schreiben settings und bersetzen fr smb.conf #######################################
1ee8bf5d 249
63d4db83 250delete $sambasettings{'__CGI__'};delete $sambasettings{'x'};delete $sambasettings{'y'};
c41c2eb4
CS
251&General::writehash("${General::swroot}/samba/settings", \%sambasettings);
252
32f77a0b 253if ($sambasettings{'PASSWORDSYNC'} eq 'on'){ $sambasettings{'PASSWORDSYNC'} = "true";} else { $sambasettings{'PASSWORDSYNC'} = "false";}
fa7be659 254if ($sambasettings{'WINSSUPPORT'} eq 'on'){ $sambasettings{'WINSSUPPORT'} = "true";$sambasettings{'WINSSRV'} = "";} else { $sambasettings{'WINSSUPPORT'} = "false";}
32f77a0b
CS
255if ($sambasettings{'LOCALMASTER'} eq 'on'){ $sambasettings{'LOCALMASTER'} = "true";} else { $sambasettings{'LOCALMASTER'} = "false";}
256if ($sambasettings{'DOMAINMASTER'} eq 'on'){ $sambasettings{'DOMAINMASTER'} = "true";} else { $sambasettings{'DOMAINMASTER'} = "false";}
257if ($sambasettings{'PREFERREDMASTER'} eq 'on'){ $sambasettings{'PREFERREDMASTER'} = "true";} else { $sambasettings{'PREFERREDMASTER'} = "false";}
97e7cfaf 258if ($sambasettings{'SYSLOGONLY'} eq 'on'){ $sambasettings{'SYSLOGONLY'} = "yes";} else { $sambasettings{'SYSLOGONLY'} = "no";}
c9f3d846
AF
259if ($sambasettings{'WIDELINKS'} eq 'on'){ $sambasettings{'WIDELINKS'} = "yes";} else { $sambasettings{'WIDELINKS'} = "no";}
260if ($sambasettings{'UNIXEXTENSION'} eq 'on'){ $sambasettings{'UNIXEXTENSION'} = "yes";} else { $sambasettings{'UNIXEXTENSION'} = "no";}
32f77a0b
CS
261
262############################################################################################################################
263############################################# Schreiben der Samba globals ##################################################
1ee8bf5d
MT
264
265 open (FILE, ">${General::swroot}/samba/global") or die "Can't save the global settings: $!";
266 flock (FILE, 2);
267
268print FILE <<END
32f77a0b
CS
269# global.settings by IPFire Project
270
271[global]
272netbios name = $sambasettings{'NETBIOSNAME'}
273server string = $sambasettings{'SRVSTRING'}
274workgroup = $sambasettings{'WORKGRP'}
00a5af61 275passdb backend = smbpasswd
32f77a0b 276
c9f3d846
AF
277wide links = $sambasettings{'WIDELINKS'}
278unix extensions = $sambasettings{'UNIXEXTENSION'}
279
32f77a0b
CS
280keep alive = 30
281os level = $sambasettings{'OSLEVEL'}
282fstype = NTFS
283
284kernel oplocks = false
285map to guest = $sambasettings{'MAPTOGUEST'}
286smb ports = 445 139
5595bc03
CS
287dos charset = $sambasettings{'DOSCHARSET'}
288unix charset = $sambasettings{'UNIXCHARSET'}
289display charset = $sambasettings{'DISPLAYCHARSET'}
32f77a0b
CS
290
291security = $sambasettings{'SECURITY'}
292encrypt passwords = yes
293guest account = $sambasettings{'GUESTACCOUNT'}
294unix password sync = $sambasettings{'PASSWORDSYNC'}
295null passwords = yes
296
297bind interfaces only = true
298interfaces = $sambasettings{'INTERFACES'}
88932936 299socket options = $sambasettings{'SOCKETOPTIONS'}
fa7be659 300remote announce = $sambasettings{'REMOTEANNOUNCE'}
2a1f6aa7 301remote browse sync = $sambasettings{'REMOTESYNC'}
32f77a0b
CS
302
303username level = 1
304wins support = $sambasettings{'WINSSUPPORT'}
fa7be659 305wins server = $sambasettings{'WINSSRV'}
32f77a0b
CS
306
307log file = /var/log/samba/samba-log.%m
308lock directory = /var/lock/samba
5595bc03 309pid directory = /var/run/
fa7be659 310log level = $sambasettings{'LOGLEVEL'}
97e7cfaf
CS
311syslog = $sambasettings{'SYSLOGLEVEL'}
312syslog only = $sambasettings{'SYSLOGONLY'}
313
32f77a0b
CS
314preferred master = $sambasettings{'PREFERREDMASTER'}
315domain master = $sambasettings{'DOMAINMASTER'}
316local master = $sambasettings{'LOCALMASTER'}
1ee8bf5d 317
32f77a0b
CS
318END
319;
320close FILE;
1ee8bf5d 321
c41c2eb4
CS
322 if (-e "${General::swroot}/cups/enable"){
323 open (FILE, ">>${General::swroot}/samba/global") or die "Can't save the global cups settings: $!";
324 flock (FILE, 2);
325 print FILE <<END
326load printers = $sambasettings{'LOADPRINTERS'}
327printing = $sambasettings{'PRINTING'}
328printcap name = $sambasettings{'PRINTCAPNAME'}
329
330END
331;
332close FILE;
333 }
334
060ecb12 335 if ($sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' )
c41c2eb4
CS
336 {
337 open (FILE, ">${General::swroot}/samba/pdc") or die "Can't save the pdc settings: $!";
338 flock (FILE, 2);
339 chomp $sambasettings{'PDCOPTIONS'};
340 $sambasettings{'PDCOPTIONS'} =~ s/\r\n/\n/gi;
341 $sambasettings{'PDCOPTIONS'} =~ s/^\n//gi;
342 $sambasettings{'PDCOPTIONS'} =~ s/^\r//gi;
343 $sambasettings{'PDCOPTIONS'} =~ s/^.\n//gi;
344 $sambasettings{'PDCOPTIONS'} =~ s/^.\r//gi;
345 print FILE <<END
32f77a0b 346$sambasettings{'PDCOPTIONS'}
1ee8bf5d
MT
347END
348;
c41c2eb4
CS
349 close FILE;
350 }
351
352if ( -e "/var/ipfire/cups/enable")
353 {
060ecb12 354 if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdccups");refreshpage();}
8871b9f2 355 else {system("/usr/local/bin/sambactrl smbsafeconfcups");}
c41c2eb4
CS
356 }
357else
358 {
060ecb12 359 if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdc");refreshpage();}
8871b9f2 360 else{system("/usr/local/bin/sambactrl smbsafeconf");}
c41c2eb4
CS
361 }
362
63d4db83 363system("/usr/local/bin/sambactrl smbreload");refreshpage();
1ee8bf5d
MT
364}
365 &General::readhash("${General::swroot}/samba/settings", \%sambasettings);
fa7be659 366
5e773594 367
c41c2eb4
CS
368if ($errormessage)
369 {
370 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
371 print "<class name='base'>$errormessage\n";
372 print "&nbsp;</class>\n";
373 &Header::closebox();
374 }
1ee8bf5d 375
14cc7eac
MT
376############################################################################################################################
377########################################## Aktivieren von Checkboxen und Dropdowns #########################################
378
97e7cfaf
CS
379$checked{'SYSLOGONLY'}{'off'} = '';
380$checked{'SYSLOGONLY'}{'on'} = '';
381$checked{'SYSLOGONLY'}{$sambasettings{'SYSLOGONLY'}} = "checked='checked'";
44254afd
MT
382$checked{'WINSSUPPORT'}{'off'} = '';
383$checked{'WINSSUPPORT'}{'on'} = '';
384$checked{'WINSSUPPORT'}{$sambasettings{'WINSSUPPORT'}} = "checked='checked'";
32f77a0b
CS
385$checked{'PASSWORDSYNC'}{'off'} = '';
386$checked{'PASSWORDSYNC'}{'on'} = '';
387$checked{'PASSWORDSYNC'}{$sambasettings{'PASSWORDSYNC'}} = "checked='checked'";
388$checked{'LOCALMASTER'}{'off'} = '';
389$checked{'LOCALMASTER'}{'on'} = '';
390$checked{'LOCALMASTER'}{$sambasettings{'LOCALMASTER'}} = "checked='checked'";
391$checked{'DOMAINMASTER'}{'off'} = '';
392$checked{'DOMAINMASTER'}{'on'} = '';
393$checked{'DOMAINMASTER'}{$sambasettings{'DOMAINMASTER'}} = "checked='checked'";
394$checked{'PREFERREDMASTER'}{'off'} = '';
395$checked{'PREFERREDMASTER'}{'on'} = '';
396$checked{'PREFERREDMASTER'}{$sambasettings{'PREFERREDMASTER'}} = "checked='checked'";
c9f3d846
AF
397$checked{'WIDELINKS'}{'off'} = '';
398$checked{'WIDELINKS'}{'on'} = '';
399$checked{'WIDELINKS'}{$sambasettings{'WIDELINKS'}} = "checked='checked'";
400$checked{'UNIXEXTENSION'}{'off'} = '';
401$checked{'UNIXEXTENSION'}{'on'} = '';
402$checked{'UNIXEXTENSION'}{$sambasettings{'UNIXEXTENSION'}} = "checked='checked'";
44254afd
MT
403$checked{'GREEN'}{'off'} = '';
404$checked{'GREEN'}{'on'} = '';
405$checked{'GREEN'}{$sambasettings{'GREEN'}} = "checked='checked'";
406$checked{'BLUE'}{'off'} = '';
407$checked{'BLUE'}{'on'} = '';
408$checked{'BLUE'}{$sambasettings{'BLUE'}} = "checked='checked'";
409$checked{'ORANGE'}{'off'} = '';
410$checked{'ORANGE'}{'on'} = '';
411$checked{'ORANGE'}{$sambasettings{'ORANGE'}} = "checked='checked'";
412$checked{'VPN'}{'off'} = '';
413$checked{'VPN'}{'on'} = '';
414$checked{'VPN'}{$sambasettings{'VPN'}} = "checked='checked'";
5e773594 415
97de2cae 416$selected{'MAPTOGUEST'}{$sambasettings{'MAPTOGUEST'}} = "selected='selected'";
97de2cae 417$selected{'SECURITY'}{$sambasettings{'SECURITY'}} = "selected='selected'";
5e773594
MT
418
419############################################################################################################################
32f77a0b 420################################### Aufbau der HTML Seite fr globale Sambaeinstellungen ###################################
5e773594 421
c9e1c143 422&Header::openbox('100%', 'center', $Lang::tr{'samba'});
5e773594 423print <<END
c41c2eb4
CS
424<br />
425<table width='95%' cellspacing='0'>
32f77a0b
CS
426END
427;
428if ( $message ne "" )
429 {
c9e1c143 430 print "<tr><td colspan='3' align='left'><font color='red'>$message</font>";
32f77a0b
CS
431 }
432
433print <<END
f2fdd0c1 434<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'all services'}</b></td></tr>
32f77a0b
CS
435</table><table width='95%' cellspacing='0'>
436END
437;
438
439my $key = '';
440foreach $key (sort keys %servicenames)
441 {
c9e1c143 442 print "<tr><td align='left' width='40%'>$key</td>";
32f77a0b
CS
443 my $shortname = $servicenames{$key};
444 my $status = &isrunning($shortname);
c9e1c143 445 print "$status</tr>";
32f77a0b
CS
446 }
447
448print <<END
32f77a0b 449</table>
92004c61 450<br />
60124059 451<table width='95%' cellspacing='0'>
60124059 452<tr><td align='left' width='40%' />
a08a5f33
CS
453<td align='center' ><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='smbstart' /><input type='image' alt='$Lang::tr{'smbstart'}' title='$Lang::tr{'smbstart'}' src='/images/go-up.png' /></form></td>
454<td align='center' ><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='smbstop' /><input type='image' alt='$Lang::tr{'smbstop'}' title='$Lang::tr{'smbstop'}' src='/images/go-down.png' /></form></td>
455<td align='center' ><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='smbrestart' /><input type='image' alt='$Lang::tr{'smbrestart'}' title='$Lang::tr{'smbrestart'}' src='/images/view-refresh.png' /></form></td></tr>
60124059 456</table>
92004c61 457<br />
32f77a0b
CS
458<form method='post' action='$ENV{'SCRIPT_NAME'}'>
459<table width='95%' cellspacing='0'>
f2fdd0c1 460<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'basic options'}</b></td></tr>
c9e1c143
CS
461<tr><td align='left' width='40%'>$Lang::tr{'workgroup'}</td><td align='left'><input type='text' name='WORKGRP' value='$sambasettings{'WORKGRP'}' size="30" /></td></tr>
462<tr><td align='left' width='40%'>$Lang::tr{'netbios name'}</td><td align='left'><input type='text' name='NETBIOSNAME' value='$sambasettings{'NETBIOSNAME'}' size="30" /></td></tr>
5595bc03
CS
463<tr><td align='left' width='40%'>$Lang::tr{'dos charset'}</td><td align='left'><input type='text' name='DOSCHARSET' value='$sambasettings{'DOSCHARSET'}' size="30" /></td></tr>
464<tr><td align='left' width='40%'>$Lang::tr{'unix charset'}</td><td align='left'><input type='text' name='UNIXCHARSET' value='$sambasettings{'UNIXCHARSET'}' size="30" /></td></tr>
465<tr><td align='left' width='40%'>$Lang::tr{'display charset'}</td><td align='left'><input type='text' name='DISPLAYCHARSET' value='$sambasettings{'DISPLAYCHARSET'}' size="30" /></td></tr>
c9e1c143
CS
466<tr><td align='left' width='40%'>$Lang::tr{'server string'}</td><td align='left'><input type='text' name='SRVSTRING' value='$sambasettings{'SRVSTRING'}' size="30" /></td></tr>
467<tr><td align='left' width='40%'>$Lang::tr{'log level'}</td><td align='left'><input type='text' name='LOGLEVEL' value='$sambasettings{'LOGLEVEL'}' size="30" /></td></tr>
97e7cfaf
CS
468<tr><td align='left' width='40%'>Sys$Lang::tr{'log level'}</td><td align='left'><input type='text' name='SYSLOGLEVEL' value='$sambasettings{'SYSLOGLEVEL'}' size="30" /></td></tr>
469<tr><td align='left' width='40%'>Syslog only</td><td align='left'>on <input type='radio' name='SYSLOGONLY' value='on' $checked{'SYSLOGONLY'}{'on'} />/
a1953287 470 <input type='radio' name='SYSLOGONLY' value='off' $checked{'SYSLOGONLY'}{'off'} /> off</td></tr>
c9e1c143 471<tr><td align='left' width='40%'>$Lang::tr{'interfaces'}</td><td align='left'>on <input type='radio' name='VPN' value='on' $checked{'VPN'}{'on'} />/
32f77a0b 472 <input type='radio' name='VPN' value='off' $checked{'VPN'}{'off'} /> off |
f57976de 473 <font size='2' color='$Header::colourovpn'><b> OpenVpn - $ovpnip[0].$ovpnip[1].$ovpnip[2].$ovpnip[3]/$ovpnnetwork[1]</b></font></td></tr>
fa7be659 474<tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='GREEN' value='on' $checked{'GREEN'}{'on'} />/
32f77a0b
CS
475 <input type='radio' name='GREEN' value='off' $checked{'GREEN'}{'off'} /> off |
476 <font size='2' color='$Header::colourgreen'><b> $Lang::tr{'green'} - $netsettings{'GREEN_DEV'}</b></font></td></tr>
477END
478;
479
480if (&Header::blue_used())
481 {
482 print <<END
fa7be659 483 <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='BLUE' value='on' $checked{'BLUE'}{'on'} />/
32f77a0b
CS
484 <input type='radio' name='BLUE' value='off' $checked{'BLUE'}{'off'} /> off |
485 <font size='2' color='$Header::colourblue'><b> $Lang::tr{'wireless'} - $netsettings{'BLUE_DEV'}</b></font></td></tr>
486END
487;
488 }
489
490if (&Header::orange_used())
491 {
492 print <<END
fa7be659 493 <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='ORANGE' value='on' $checked{'ORANGE'}{'on'} />/
32f77a0b
CS
494 <input type='radio' name='ORANGE' value='off' $checked{'ORANGE'}{'off'} /> off |
495 <font size='2' color='$Header::colourorange'><b> $Lang::tr{'dmz'} - $netsettings{'ORANGE_DEV'}</b></font></td></tr>
496END
497;
498 }
499
500print <<END
c9e1c143 501<tr><td align='center' width='40%'>$Lang::tr{'more'}</td><td align='left'><input type='text' name='OTHERINTERFACES' value='$sambasettings{'OTHERINTERFACES'}' size="30" /></td></tr>
32f77a0b 502<tr><td align='left'><br /></td><td></td></tr>
c9f3d846
AF
503<tr><td align='left' width='40%'>Wide links</td><td align='left'>on <input type='radio' name='WIDELINKS' value='on' $checked{'WIDELINKS'}{'on'} />/
504 <input type='radio' name='WIDELINKS' value='off' $checked{'WIDELINKS'}{'off'} /> off</td></tr>
505<tr><td align='left' width='40%'>Unix extension</td><td align='left'>on <input type='radio' name='UNIXEXTENSION' value='on' $checked{'UNIXEXTENSION'}{'on'} />/
506 <input type='radio' name='UNIXEXTENSION' value='off' $checked{'UNIXEXTENSION'}{'off'} /> off</td></tr>
507<tr><td align='left'><br /></td><td></td></tr>
f2fdd0c1 508<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'security options'}</b></td></tr>
c9e1c143 509<tr><td align='left' width='40%'>$Lang::tr{'security'}</td><td align='left'><select name='SECURITY' style="width: 165px">
32f77a0b
CS
510 <option value='share' $selected{'SECURITY'}{'share'}>Share</option>
511 <option value='user' $selected{'SECURITY'}{'user'}>User</option>
512 <option value='domain' $selected{'SECURITY'}{'domain'}>Domain</option>
513 <option value='ADS' $selected{'SECURITY'}{'ADS'}>ADS</option>
514 <option value='server' $selected{'SECURITY'}{'server'}>Server</option>
515 </select></td></tr>
c9e1c143 516<tr><td align='left' width='40%'>$Lang::tr{'map to guest'}</td><td align='left'><select name='MAPTOGUEST' style="width: 165px">
32f77a0b
CS
517 <option value='Never' $selected{'MAPTOGUEST'}{'Never'}>Never</option>
518 <option value='Bad User' $selected{'MAPTOGUEST'}{'Bad User'}>Bad User</option>
519 <option value='Bad Password' $selected{'MAPTOGUEST'}{'Bad Password'}>Bad Password</option>
520 </select></td></tr>
2a1f6aa7
CS
521END
522;
523#<tr><td align='left' width='40%'>$Lang::tr{'unix password sync'}</td><td align='left'>on <input type='radio' name='PASSWORDSYNC' value='on' $checked{'PASSWORDSYNC'}{'on'} />/
524# <input type='radio' name='PASSWORDSYNC' value='off' $checked{'PASSWORDSYNC'}{'off'} /> off</td></tr>
525print <<END
fa7be659 526<tr><td align='left'><br /></td><td /></tr>
f2fdd0c1 527<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'network options'}</b></td></tr>
c9e1c143 528<tr><td align='left' width='40%'>$Lang::tr{'os level'}</td><td align='left'><input type='text' name='OSLEVEL' value='$sambasettings{'OSLEVEL'}' size="30" /></td></tr>
88932936 529<tr><td align='left' width='40%'>$Lang::tr{'socket options'}</td><td align='left'><input type='text' name='SOCKETOPTIONS' value='$sambasettings{'SOCKETOPTIONS'}' size="30" /></td></tr>
c9e1c143 530<tr><td align='left' width='40%'>$Lang::tr{'remote announce'}</td><td align='left'><input type='text' name='REMOTEANNOUNCE' value='$sambasettings{'REMOTEANNOUNCE'}' size="30" /></td></tr>
fcd5cb6f 531<tr><td align='left' width='40%'>$Lang::tr{'remote browse sync'}</td><td align='left'><input type='text' name='REMOTESYNC' value='$sambasettings{'REMOTESYNC'}' size="30" /></td></tr>
fa7be659
CS
532END
533;
c9e1c143 534if ($sambasettings{'WINSSUPPORT'} eq 'off') {print"<tr><td align='left' width='40%'>$Lang::tr{'wins server'}</td><td align='left'><input type='text' name='WINSSRV' value='$sambasettings{'WINSSRV'}' size='30' /></td></tr>";}
fa7be659 535 print <<END
c9e1c143 536<tr><td align='left' width='40%'>$Lang::tr{'wins support'}</td><td align='left'>on <input type='radio' name='WINSSUPPORT' value='on' $checked{'WINSSUPPORT'}{'on'} />/
fa7be659 537 <input type='radio' name='WINSSUPPORT' value='off' $checked{'WINSSUPPORT'}{'off'} /> off</td></tr>
32f77a0b
CS
538END
539;
540
541if ($sambasettings{'SECURITY'} eq 'user')
542 {
543 print <<END
c9e1c143 544<tr><td align='left' width='40%'>$Lang::tr{'local master'}</td><td align='left'>on <input type='radio' name='LOCALMASTER' value='on' $checked{'LOCALMASTER'}{'on'} />/
32f77a0b 545 <input type='radio' name='LOCALMASTER' value='off' $checked{'LOCALMASTER'}{'off'} /> off</td></tr>
c9e1c143 546<tr><td align='left' width='40%'>$Lang::tr{'domain master'}</td><td align='left'>on <input type='radio' name='DOMAINMASTER' value='on' $checked{'DOMAINMASTER'}{'on'} />/
32f77a0b 547 <input type='radio' name='DOMAINMASTER' value='off' $checked{'DOMAINMASTER'}{'off'} /> off</td></tr>
c9e1c143 548<tr><td align='left' width='40%'>$Lang::tr{'prefered master'}</td><td align='left'>on <input type='radio' name='PREFERREDMASTER' value='on' $checked{'PREFERREDMASTER'}{'on'} />/
32f77a0b
CS
549 <input type='radio' name='PREFERREDMASTER' value='off' $checked{'PREFERREDMASTER'}{'off'} /> off</td></tr>
550END
551;
552 }
553
554if ($sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'on')
555 {
556 print <<END
557 <tr><td align='left'><br /></td><td></td></tr>
f2fdd0c1 558 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'pdc options'}</b></td></tr>
32f77a0b
CS
559 <tr><td align='left'><br /></td><td></td></tr>
560 <tr><td colspan='2' align='center'><textarea name="PDCOPTIONS" cols="50" rows="15" Wrap="off">$PDCOPTIONS</textarea></td></tr>
561END
c41c2eb4
CS
562;
563 }
564
565 if ( -e "/var/ipfire/cups/enable")
566 {
567 print <<END
568 <tr><td align='left'><br /></td><td></td></tr>
f2fdd0c1 569 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'printing options'}</b></td></tr>
c41c2eb4
CS
570 <tr><td align='left' width='40%'>$Lang::tr{'load printer'}</td><td align='left'><input type='text' name='LOADPRINTERS' value='$sambasettings{'LOADPRINTERS'}' size="30" /></td></tr>
571 <tr><td align='left' width='40%'>$Lang::tr{'printing'}</td><td align='left'><input type='text' name='PRINTING' value='$sambasettings{'PRINTING'}' size="30" /></td></tr>
572 <tr><td align='left' width='40%'>$Lang::tr{'printcap name'}</td><td align='left'><input type='text' name='PRINTCAPNAME' value='$sambasettings{'PRINTCAPNAME'}' size="30" /></td></tr>
573END
32f77a0b
CS
574;
575 }
576
577print <<END
578</table>
92004c61 579<br />
32f77a0b 580<table width='10%' cellspacing='0'>
32f77a0b
CS
581<tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
582 <input type='hidden' name='ACTION' value=$Lang::tr{'save'} />
a08a5f33 583 <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></form></td>
32f77a0b
CS
584<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
585 <input type='hidden' name='ACTION' value='globalreset' />
a08a5f33 586 <input type='image' alt='$Lang::tr{'reset'}' title='$Lang::tr{'reset'}' src='/images/reload.gif' /></form></td>
32f77a0b
CS
587<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
588 <input type='hidden' name='ACTION' value='globalcaption' />
a08a5f33 589 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form></td></tr>
32f77a0b 590</table>
44254afd
MT
591END
592;
32f77a0b 593
44254afd 594if ($sambasettings{'ACTION'} eq 'globalcaption')
32f77a0b
CS
595 {
596 print <<END
92004c61 597 <br />
32f77a0b 598 <table width='95%' cellspacing='0'>
c9e1c143 599 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
60124059 600 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save settings'}</td></tr>
c9e1c143 601 <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'restore settings'}</td></tr>
32f77a0b 602 </table>
5e773594
MT
603END
604;
32f77a0b
CS
605 }
606
5e773594
MT
607&Header::closebox();
608
14cc7eac 609############################################################################################################################
32f77a0b 610########################################## Benutzerverwaltung fr Usersecurity #############################################
14cc7eac 611
1ee8bf5d 612if ($sambasettings{'SECURITY'} eq 'user')
32f77a0b
CS
613 {
614 if ($sambasettings{'DOMAINMASTER'} eq 'off')
615 {
c9e1c143 616 &Header::openbox('100%', 'center', $Lang::tr{'accounting user nonpdc'});
32f77a0b
CS
617 }
618 else
619 {
c9e1c143 620 &Header::openbox('100%', 'center', $Lang::tr{'accounting user pdc'});
32f77a0b
CS
621 }
622 print <<END
19f5a6cc 623 <a name="$Lang::tr{'accounting'}"</a>
92004c61 624 <br />
32f77a0b 625 <table width='95%' cellspacing='0'>
32f77a0b 626 <tr><td colspan='6' align='left'></td></tr>
f2fdd0c1 627 <tr><td bgcolor='$color{'color20'}' colspan='7' align='left'><b>$Lang::tr{'accounting'}</b></td></tr>
c9e1c143 628 <tr><td align='left'><u>$Lang::tr{'username'}</u></td><td align='left'><u>$Lang::tr{'password'}</u></td>
32f77a0b
CS
629END
630;
5e773594 631
32f77a0b
CS
632 if ($sambasettings{'DOMAINMASTER'} eq 'off')
633 {
634 print "<td></td>";
635 }
636 else
637 {
92004c61 638 print "<td align='left'><u>$Lang::tr{'type'}</u></td>";
32f77a0b
CS
639 }
640
92004c61 641 print "<td align='left'><u>$Lang::tr{'status'}</u></td><td colspan='3' width='5%' align='center'><u>$Lang::tr{'options'}</u></td></tr>";
32f77a0b 642 system('/usr/local/bin/sambactrl readsmbpasswd');
c41c2eb4 643 open(FILE, "<${General::swroot}/samba/private/smbpasswd") or die "Can't read user file: $!";
32f77a0b
CS
644 @user = <FILE>;
645 close(FILE);
646 system('/usr/local/bin/sambactrl locksmbpasswd');
a28fdc01
CS
647
648 my $lines = 0;
649
32f77a0b
CS
650 foreach $userentry (sort @user)
651 {
652 @userline = split( /\:/, $userentry );
a28fdc01
CS
653 if ($lines % 2) {print "<tr bgcolor='$color{'color20'}'>";} else {print "<tr bgcolor='$color{'color22'}'>";}
654 print "<td align='left'>$userline[0]</td><td align='left'>";
32f77a0b
CS
655 if ($userline[4] =~ /N/)
656 {
c9e1c143 657 print "$Lang::tr{'not set'}</td><td align='left'>";
32f77a0b
CS
658 }
659 else
660 {
c9e1c143 661 print "$Lang::tr{'set'}</td><td align='left'>";
32f77a0b
CS
662 }
663
664 if ($sambasettings{'DOMAINMASTER'} eq 'off')
665 {
fa7be659 666 print "</td><td align='left'>";
32f77a0b
CS
667 }
668 else
669 {
670 if ($userline[0] =~ /\$/)
671 {
71dfc4b7 672 print "$Lang::tr{'pc'}</td><td align='left'>";
32f77a0b
CS
673 }
674 else
675 {
c9e1c143 676 print "$Lang::tr{'user'}</td><td align='left'>";
32f77a0b
CS
677 }
678 }
679
680 if ($userline[4] =~ /D/)
681 {
682 print <<END
92004c61 683 $Lang::tr{'inactive'}</td>
19f5a6cc 684 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b
CS
685 <input type='hidden' name='NAME' value='$userline[0]' />
686 <input type='hidden' name='ACTION' value='smbuserenable' />
25943d3b 687 <input type='image' alt='$Lang::tr{'activate'}' title='$Lang::tr{'activate'}' src='/images/off.gif' />
32f77a0b
CS
688 </form></td>
689END
690;
691 }
692 else
693 {
694 print <<END
92004c61 695 $Lang::tr{'active'}</td>
19f5a6cc 696 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b
CS
697 <input type='hidden' name='NAME' value='$userline[0]' />
698 <input type='hidden' name='ACTION' value='smbuserdisable' />
25943d3b 699 <input type='image' alt='$Lang::tr{'deactivate'}' title='$Lang::tr{'deactivate'}' src='/images/on.gif' />
32f77a0b
CS
700 </form></td>
701END
702;
703 }
704
705 if ($userline[0] =~ /\$/)
706 {
707 print "<td></td>";
708 }
709 else
710 {
711 print <<END
19f5a6cc 712 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b
CS
713 <input type='hidden' name='NAME' value='$userline[0]' />
714 <input type='hidden' name='ACTION' value='userchangepw' />
a08a5f33 715 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
32f77a0b
CS
716 </form></td>
717END
718;
719 }
720
fa7be659
CS
721 if ($sambasettings{'DOMAINMASTER'} eq 'on' && $userline[0] =~ /\$/)
722 {
723 print <<END
19f5a6cc 724 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
fa7be659
CS
725 <input type='hidden' name='NAME' value='$userline[0]' />
726 <input type='hidden' name='ACTION' value='userdelete' />
a08a5f33 727 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/network-error.png' />
fa7be659
CS
728 </form></td></tr>
729END
730;
731 }
732 else
733 {
734 print <<END
19f5a6cc 735 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
fa7be659
CS
736 <input type='hidden' name='NAME' value='$userline[0]' />
737 <input type='hidden' name='ACTION' value='userdelete' />
a08a5f33 738 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-option-remove.png' />
fa7be659 739 </form></td></tr>
32f77a0b
CS
740END
741;
fa7be659 742 }
a28fdc01 743 $lines++;
32f77a0b
CS
744 }
745 print <<END
746 </table>
92004c61 747 <br />
32f77a0b 748 <table width='10%' cellspacing='0'>
19f5a6cc 749 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b 750 <input type='hidden' name='ACTION' value='useradd' />
a08a5f33 751 <input type='image' alt='$Lang::tr{'add user'}' title='$Lang::tr{'add user'}' src='/images/user-option-add.png' /></form></td>
5e773594
MT
752END
753;
1ee8bf5d 754
32f77a0b
CS
755 if ($sambasettings{'DOMAINMASTER'} eq 'on')
756 {
757 print <<END
19f5a6cc 758 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b 759 <input type='hidden' name='ACTION' value='pcadd' />
a08a5f33 760 <input type='image' alt='$Lang::tr{'pc add'}' title='$Lang::tr{'pc add'}' src='/images/network.png' /></form>
32f77a0b
CS
761END
762;
763 }
764 print <<END
19f5a6cc 765 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b 766 <input type='hidden' name='ACTION' value='usercaption' />
a08a5f33 767 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form>
94819213 768 </td></tr>
32f77a0b
CS
769 </table>
770END
771;
44254afd 772
32f77a0b
CS
773 if ($sambasettings{'ACTION'} eq 'usercaption')
774 {
775 print <<END
92004c61 776 <br />
32f77a0b 777 <table width='95%' cellspacing='0'>
c9e1c143
CS
778 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
779 <tr><td align='right' width='33%'><img src='/images/user-option-add.png' /></td><td align='left'>$Lang::tr{'add user'}</td></tr>
115340d2 780 <tr><td align='right' width='33%'><img src='/images/network.png' /></td><td align='left'>$Lang::tr{'pc add'}</td></tr>
c9e1c143
CS
781 <tr><td align='right' width='33%'><img src='/images/user-option-remove.png' /></td><td align='left'>$Lang::tr{'delete user'}</td></tr>
782 <tr><td align='right' width='33%'><img src='/images/network-error.png' /></td><td align='left'>$Lang::tr{'delete pc'}</td></tr>
25943d3b
CS
783 <tr><td align='right' width='33%'><img src='/images/off.gif' /></td><td align='left'>$Lang::tr{'activate user'}</td></tr>
784 <tr><td align='right' width='33%'><img src='/images/on.gif' /></td><td align='left'>$Lang::tr{'deactivate user'}</td></tr>
c9e1c143 785 <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'change passwords'}</td></tr>
60124059 786 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr>
32f77a0b 787 </table>
1ee8bf5d
MT
788END
789;
32f77a0b
CS
790 }
791
792 if ($sambasettings{'ACTION'} eq 'userchangepw')
793 {
794 my $username = "$sambasettings{'NAME'}";
795 my $password = 'samba';
796 print <<END
92004c61 797 <br />
19f5a6cc 798 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b 799 <table width='95%' cellspacing='0'>
f2fdd0c1 800 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'change passwords'}</b></td></tr>
1e482cb6 801 <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' readonly /></td></tr>
c9e1c143 802 <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr>
32f77a0b 803 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbchangepw' />
a08a5f33 804 <input type='image' alt=$Lang::tr{'save'} title=$Lang::tr{'save'} src='/images/media-floppy.png' /></td></tr>
32f77a0b 805 </table>
94819213 806 </form>
1ee8bf5d
MT
807END
808;
32f77a0b
CS
809 }
810
811 if ($sambasettings{'ACTION'} eq 'useradd')
812 {
813 my $username = "user";
814 my $password = "samba";
815 chomp $username;
816 $username=~s/\s//g;
817 chomp $password;
818 $password=~s/\s//g;
819 print <<END
92004c61 820 <br />
19f5a6cc 821 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b 822 <table width='95%' cellspacing='0'>
f2fdd0c1 823 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add user'}</b></td></tr>
c9e1c143
CS
824 <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' /></td></tr>
825 <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr>
826 <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambauser' size='30' /></td></tr>
827 <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr>
32f77a0b 828 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbuseradd' />
a08a5f33 829 <input type='image' alt=$Lang::tr{'save'} title=$Lang::tr{'save'} src='/images/media-floppy.png' /></td></tr>
32f77a0b 830 </table>
94819213 831 </form>
32f77a0b
CS
832END
833;
834 }
835
836 if ($sambasettings{'ACTION'} eq 'pcadd')
837 {
838 my $pcname = "client\$";
839 chomp $pcname;
840 $pcname=~s/\s//g;
841 print <<END
92004c61 842 <br />
19f5a6cc 843 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b 844 <table width='95%' cellspacing='0'>
f2fdd0c1 845 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'pc add'}</b></td></tr>
c9e1c143
CS
846 <tr><td align='left'>$Lang::tr{'client'}</td><td><input type='text' name='PCNAME' value='$pcname' size='30' /></td></tr>
847 <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambawks' size='30' /></td></tr>
848 <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr>
32f77a0b 849 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbpcadd' />
a08a5f33 850 <input type='image' title=$Lang::tr{'save'} alt=$Lang::tr{'save'} src='/images/media-floppy.png' /></td></tr>
32f77a0b 851 </table>
94819213 852 </form>
32f77a0b
CS
853END
854;
855 }
97de2cae
MT
856
857&Header::closebox();
1ee8bf5d 858}
14cc7eac
MT
859
860############################################################################################################################
861############################################### Verwalten von Freigaben ####################################################
fa7be659 862
c9e1c143 863&Header::openbox('100%', 'center', $Lang::tr{'shares'});
97de2cae 864
c41c2eb4
CS
865my %shares = config("${General::swroot}/samba/shares");
866
867
1ee8bf5d 868print <<END
19f5a6cc 869<a name="$Lang::tr{'manage shares'}"</a>
92004c61 870<br />
32f77a0b 871<table width='95%' cellspacing='0'>
f2fdd0c1 872<tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'manage shares'}</b>
c9e1c143 873<tr><td align='left'><u>$Lang::tr{'sharename'}</u></td><td colspan='2' width="5%" align='center'><u>$Lang::tr{'options'}</u></td></tr>
1ee8bf5d
MT
874END
875;
14cc7eac 876
c41c2eb4 877my @Shares = keys(%shares);
a28fdc01 878my $lines = 0;
c41c2eb4
CS
879
880foreach my $shareentry (sort @Shares)
32f77a0b 881 {
c41c2eb4 882 chomp $shareentry;
a28fdc01 883 if ($lines % 2) {print "<tr bgcolor='$color{'color20'}'>";} else {print "<tr bgcolor='$color{'color22'}'>";}
32f77a0b 884 print <<END
a28fdc01 885 <td align='left'>$shareentry</td>
19f5a6cc 886 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
32f77a0b
CS
887 <input type='hidden' name='NAME' value='$shareentry' />
888 <input type='hidden' name='ACTION' value='sharechange' />
a08a5f33 889 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
32f77a0b 890 </form></td>
96742484 891 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
32f77a0b
CS
892 <input type='hidden' name='NAME' value='$shareentry' />
893 <input type='hidden' name='ACTION' value='smbsharedel' />
a08a5f33 894 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' />
94819213 895 </form></td></tr>
32f77a0b
CS
896END
897;
a28fdc01 898 $lines++;
32f77a0b
CS
899 }
900
901print <<END
902</table>
92004c61 903<br />
32f77a0b 904<table width='10%' cellspacing='0'>
19f5a6cc 905<tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
94819213 906 <input type='hidden' name='ACTION' value='shareadd' />
a08a5f33 907 <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/list-add.png' />
32f77a0b 908 </form></td>
19f5a6cc 909 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
94819213 910 <input type='hidden' name='ACTION' value='sharesreset' />
a08a5f33 911 <input type='image' alt='$Lang::tr{'reset'}' title='$Lang::tr{'reset'}' src='/images/reload.gif' />
32f77a0b 912 </form></td>
19f5a6cc 913 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
88932936 914 <input type='hidden' name='ACTION' value='sharecaption' />
a08a5f33 915 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' />
88932936
CS
916 </form></td>
917</tr>
32f77a0b 918</table>
1ee8bf5d
MT
919END
920;
32f77a0b 921
1ee8bf5d 922if ($sambasettings{'ACTION'} eq 'sharecaption')
32f77a0b
CS
923 {
924 print <<END
92004c61 925 <br />
32f77a0b 926 <table width='95%' cellspacing='0'>
92004c61 927 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
60124059 928 <tr><td align='right' width='33%'><img src='/images/list-add.png' /></td><td align='left'>$Lang::tr{'add share'}</td></tr>
c9e1c143 929 <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'edit share'}</td></tr>
60124059 930 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr>
c9e1c143 931 <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'reset shares'}</td></tr>
60124059 932 <tr><td align='right' width='33%'><img src='/images/user-trash.png' /></td><td align='left'>$Lang::tr{'delete share'}</td></tr>
32f77a0b 933 </table>
1ee8bf5d
MT
934END
935;
32f77a0b 936 }
97de2cae 937
1ee8bf5d 938if ($sambasettings{'ACTION'} eq 'shareadd' || $sambasettings{'ACTION'} eq 'optioncaption' )
32f77a0b
CS
939 {
940 print <<END
92004c61 941 <br />
32f77a0b 942 <table width='95%' cellspacing='0'>
f2fdd0c1 943 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add share'}</b></td></tr>
32f77a0b 944 <tr><td colspan='2' align='center'></td></tr>
88932936 945 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}
c41c2eb4 946 <a href="sambahlp.cgi" target="popup" onClick="window.open ('', 'popup', 'width=580,height=600,scrollbars=yes, toolbar=no,status=no, resizable=yes,menubar=no,location=no,directories=no,top=10,left=10')"><img border="0" src="/images/help-browser.png"></a></td></tr>
19f5a6cc 947 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'><tr><td colspan='2' align='center'><textarea name="SHAREOPTION" cols="50" rows="15" Wrap="off">$defaultoption</textarea></td></tr>
32f77a0b 948 </table>
92004c61 949 <br />
32f77a0b 950 <table width='10%' cellspacing='0'>
94819213 951 <tr><td align='center'><input type='hidden' name='ACTION' value='smbshareadd' />
a08a5f33 952 <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/media-floppy.png' /></td></tr></form>
32f77a0b 953 </table>
5e773594
MT
954END
955;
32f77a0b 956 }
5e773594 957
1ee8bf5d 958if ($sambasettings{'ACTION'} eq 'sharechange' || $sambasettings{'ACTION'} eq 'optioncaption2' )
32f77a0b 959 {
c41c2eb4 960 my $shareoption = $shares{$sambasettings{'NAME'}};
32f77a0b 961 print <<END
92004c61 962 <br />
32f77a0b 963 <table width='95%' cellspacing='0'>
f2fdd0c1 964 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'edit share'}</b></td></tr>
32f77a0b 965 <tr><td colspan='2' align='center'></td></tr>
c41c2eb4 966 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}<a href="sambahlp.cgi" target="popup" onClick="window.open ('', 'popup', 'width=580,height=600,scrollbars=yes, toolbar=no,status=no, resizable=yes,menubar=no,location=no,directories=no,top=10,left=10')"><img border="0" src="/images/help-browser.png"></a></td></tr>
19f5a6cc 967 <tr><td colspan='2' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'><textarea name="SHAREOPTION" cols="50" rows="15" Wrap="off">$shareoption</textarea></td></tr>
32f77a0b 968 </table>
92004c61 969 <br />
32f77a0b 970 <table width='10%' cellspacing='0'>
94819213 971 <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' />
a08a5f33 972 <input type='image' alt='$Lang::tr{'change share'}' title='$Lang::tr{'change share'}' src='/images/media-floppy.png' />
fa7be659 973 <input type='hidden' name='ACTION' value='smbsharechange' /></form></td></tr>
32f77a0b 974 </table>
1ee8bf5d
MT
975END
976;
32f77a0b 977 }
5e773594 978
c41c2eb4
CS
979if ($sambasettings{'ACTION'} eq 'sharesresetyes')
980 {
981 system('/usr/local/bin/sambactrl smbsharesreset');
982 my $shares = config("${General::swroot}/samba/shares");
983 system("/usr/local/bin/sambactrl smbreload");
984 }
985if ($sambasettings{'ACTION'} eq 'smbshareadd')
986 {
987 $shares{'xvx'}= "$sambasettings{'SHAREOPTION'}";
988 save("shares");
989 my $shares = config("${General::swroot}/samba/shares");
990 }
991if ($sambasettings{'ACTION'} eq 'smbsharedel')
992 {
993 delete $shares{$sambasettings{'NAME'}};
994 save("shares");
995 my %shares = config("${General::swroot}/samba/shares");
996 }
997if ($sambasettings{'ACTION'} eq 'smbsharechange')
998 {
999 $shares{$sambasettings{'NAME'}} = $sambasettings{'SHAREOPTION'};
1000 save("shares");
1001 my %shares = config("${General::swroot}/samba/shares");
1002 }
1003
1004&Header::closebox();
1005
1006############################################################################################################################
1007################################################ Verwalten von Druckern ####################################################
1008
1009my %printer = config("${General::swroot}/samba/printer");
1010
1011if ( -e "/var/ipfire/cups/enable")
1012{
1013&Header::openbox('100%', 'center', $Lang::tr{'printer'});
1014
1015my @Printers = keys(%printer);
1016print <<END
19f5a6cc 1017<a name="$Lang::tr{'manage printers'}"</a>
c41c2eb4
CS
1018<br />
1019<table width='95%' cellspacing='0'>
f2fdd0c1 1020<tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'manage printers'}</b>
c41c2eb4
CS
1021<tr><td align='left'><u>$Lang::tr{'printername'}</u></td><td colspan='2' width="5%" align='center'><u>$Lang::tr{'options'}</u></td></tr>
1022END
1023;
1024foreach my $printerentry (sort @Printers)
1025 {
1026 chomp $printerentry;
1027 print <<END
1028 <tr><td align='left'>$printerentry</td>
19f5a6cc 1029 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
c41c2eb4
CS
1030 <input type='hidden' name='NAME' value='$printerentry' />
1031 <input type='hidden' name='ACTION' value='printerchange' />
a08a5f33 1032 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
c41c2eb4 1033 </form></td>
19f5a6cc 1034 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
c41c2eb4
CS
1035 <input type='hidden' name='NAME' value='$printerentry' />
1036 <input type='hidden' name='ACTION' value='smbprinterdel' />
a08a5f33 1037 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' />
c41c2eb4
CS
1038 </form></td></tr>
1039END
1040;
1041 }
1042print <<END
1043</table>
1044<br />
1045<table width='10%' cellspacing='0'>
19f5a6cc 1046<tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
c41c2eb4 1047 <input type='hidden' name='ACTION' value='printeradd' />
a08a5f33 1048 <input type='image' alt='$Lang::tr{'add printer'}' title='$Lang::tr{'add printer'}' src='/images/list-add.png' />
c41c2eb4 1049 </form></td>
19f5a6cc 1050 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
c41c2eb4 1051 <input type='hidden' name='ACTION' value='printereset' />
a08a5f33 1052 <input type='image' alt='$Lang::tr{'reset'}' title='$Lang::tr{'reset'}' src='/images/reload.gif' />
c41c2eb4 1053 </form></td>
19f5a6cc 1054 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
c41c2eb4 1055 <input type='hidden' name='ACTION' value='printercaption' />
a08a5f33 1056 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' />
c41c2eb4
CS
1057 </form></td>
1058</tr>
1059</table>
1060END
1061;
1062
1063if ($sambasettings{'ACTION'} eq 'printeradd' || $sambasettings{'ACTION'} eq 'printercaption' )
1064 {
1065 print <<END
c41c2eb4
CS
1066 <br />
1067 <table width='95%' cellspacing='0'>
f2fdd0c1 1068 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add printer'}</b></td></tr>
c41c2eb4
CS
1069 <tr><td colspan='2' align='center'></td></tr>
1070 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}
1071 <a href="sambahlp.cgi" target="popup" onClick="window.open ('', 'popup', 'width=580,height=600,scrollbars=yes, toolbar=no,status=no, resizable=yes,menubar=no,location=no,directories=no,top=10,left=10')"><img border="0" src="/images/help-browser.png"></a></td></tr>
19f5a6cc 1072 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'><tr><td colspan='2' align='center'><textarea name="PRINTEROPTION" cols="50" rows="15" Wrap="off">$defaultprinter</textarea></td></tr>
c41c2eb4
CS
1073 </table>
1074 <br />
1075 <table width='10%' cellspacing='0'>
1076 <tr><td align='center'><input type='hidden' name='ACTION' value='smbprinteradd' />
a08a5f33 1077 <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/media-floppy.png' /></td></tr>
c41c2eb4
CS
1078 </table>
1079 </form>
1080END
1081;
1082 }
1083
1084if ($sambasettings{'ACTION'} eq 'printerchange' || $sambasettings{'ACTION'} eq 'printercaption2' )
1085 {
1086 my $printeroption = $printer{$sambasettings{'NAME'}};
1087 print <<END
c41c2eb4
CS
1088 <br />
1089 <table width='95%' cellspacing='0'>
f2fdd0c1 1090 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'edit printer'}</b></td></tr>
c41c2eb4
CS
1091 <tr><td colspan='2' align='center'></td></tr>
1092 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}<a href="sambahlp.cgi" target="popup" onClick="window.open ('', 'popup', 'width=580,height=600,scrollbars=yes, toolbar=no,status=no, resizable=yes,menubar=no,location=no,directories=no,top=10,left=10')"><img border="0" src="/images/help-browser.png"></a></td></tr>
19f5a6cc 1093 <tr><td colspan='2' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'><textarea name="PRINTEROPTION" cols="50" rows="15" Wrap="off">$printeroption</textarea></td></tr>
c41c2eb4
CS
1094 </table>
1095 <br />
1096 <table width='10%' cellspacing='0'>
1097 <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' />
a08a5f33 1098 <input type='image' alt='$Lang::tr{'change share'}' title='$Lang::tr{'change share'}' src='/images/media-floppy.png' />
c41c2eb4
CS
1099 <input type='hidden' name='ACTION' value='smbprinterchange' /></form></td></tr>
1100 </table>
1101END
1102;
1103 }
1104
1105if ($sambasettings{'ACTION'} eq 'smbprinteradd')
1106 {
1107 $printer{'xvx'}= "$sambasettings{'PRINTEROPTION'}";
1108 save("printer");
1109 my %printer = config("${General::swroot}/samba/printer");
1110 }
1111
1112if ($sambasettings{'ACTION'} eq 'smbprinterdel')
1113 {
1114 delete $printer{$sambasettings{'NAME'}};
1115 save("printer");
1116 my %printer = config("${General::swroot}/samba/printer");
1117 }
1118
1119if ($sambasettings{'ACTION'} eq 'smbprinterchange')
1120 {
1121 $printer{$sambasettings{'NAME'}} = $sambasettings{'PRINTEROPTION'};
1122 save("printer");
1123 my %printer = config("${General::swroot}/samba/printer");
1124 }
1125
32f77a0b 1126&Header::closebox();
c41c2eb4 1127}
32f77a0b
CS
1128
1129############################################################################################################################
1130############################################### Anzeige des Sambastatus ####################################################
1131
1132&Header::openbox('100%', 'center', 'Status');
1133
1134print <<END
92004c61 1135<br />
32f77a0b 1136<table width='95%' cellspacing='0'>
f2fdd0c1 1137<tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'samba status'}</b></td></tr>
fa7be659
CS
1138<tr><td align='left'>$Status</td></tr>
1139</table>
1140END
1141;
1142&Header::closebox();
1143
1144############################################################################################################################
c41c2eb4 1145############################################### Anzeige der Sambalogs ######################################################
fa7be659
CS
1146
1147
1148if ($sambasettings{'ACTION'} eq 'showlog')
1149{
c41c2eb4 1150$Log = qx(tail -n $sambasettings{'LOGLINES'} /var/log/samba/$sambasettings{'LOG'});
fa7be659
CS
1151$Log=~s/\n/<br \/>/g;
1152}
1153
c9e1c143 1154&Header::openbox('100%', 'center', $Lang::tr{'log'});
fa7be659
CS
1155
1156print <<END
19f5a6cc 1157<a name="$Lang::tr{'log view'}"</a>
92004c61 1158<br />
19f5a6cc 1159<form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'log view'}'>
fa7be659 1160<table width='95%' cellspacing='0'>
f2fdd0c1 1161<tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'log view'}</b></td></tr>
fa7be659
CS
1162<tr><td colspan='3' align='left'><br /></td></tr>
1163<tr><td align='left'><select name='LOG' style="width: 200px">
1164END
1165;
1166foreach my $log (@Logs) {chomp $log;print"<option value='$log'>$log</option>";}
1167print <<END
1168
c9e1c143 1169</select></td><td align='left'>$Lang::tr{'show last x lines'}<input type='text' name='LOGLINES' value='$LOGLINES' size="3" /></td>
a08a5f33 1170 <td align='left'><input type='hidden' name='ACTION' value='showlog' /><input type='image' alt='view Log' title='view Log' src='/images/format-justify-fill.png' /></td></tr>
fa7be659
CS
1171<tr><td colspan='3' align='left'><br /></td></tr>
1172<tr><td colspan='3' align='left'><font size=2>$Log</font></td></tr>
1173<tr><td colspan='3' align='left'><br /></td></tr>
1174<tr><td colspan='3' align='center'>$sambasettings{'LOG'}</td></tr>
32f77a0b 1175</table>
fa7be659 1176</form>
32f77a0b
CS
1177END
1178;
1ee8bf5d 1179&Header::closebox();
5e773594
MT
1180&Header::closebigbox();
1181&Header::closepage();
1182
1183############################################################################################################################
fa7be659 1184############################################ Subfunktion fr Sambadienste ###################################################
5e773594 1185
c41c2eb4
CS
1186sub config
1187{
1188my $file = shift;
1189my @allarray = `grep -n '^\\[' $file`;
1190my @linesarray = ();
1191my @namearray = ();
1192my %hash = ();
1193my $options = ();
1194my $EOF = qx(cat $file | wc -l);
1195foreach my $allarrayentry (@allarray)
1196 {
1197 my @allarrayline = split( /\:/, $allarrayentry );
1198 push(@linesarray,$allarrayline[0]);$allarrayline[1]=~s/\[//g;$allarrayline[1]=~s/\]//g;push(@namearray,$allarrayline[1]);
1199 }
1200 for(my $i = 0; $i <= $#namearray; $i++)
1201 {
1202 chomp $namearray[$i];
1203 $namearray[$i]=~s/\[//g;$namearray[$i]=~s/\]//g;
1204 if ( $i eq $#namearray )
1205 {
1206 my $lineend = $EOF-$linesarray[$i]+1;
1207 $options=qx(tail -$lineend $file);
1208 }
1209 else
1210 {
1211 my $linestart = $EOF-$linesarray[$i]+1;
1212 my $lineend = $linesarray[$i+1]-$linesarray[$i];
1213 $options=qx(tail -$linestart $file | head -$lineend);
1214 }
1215 $hash{$namearray[$i]} = "$options";
1e482cb6 1216 #print"<pre>$namearray[$i]\n$options\n</pre>"; # enable only for debuging
c41c2eb4
CS
1217 }
1218return(%hash);
1219}
1220
1221sub save
1222{
1223my $smb = shift;
1224open (FILE, ">${General::swroot}/samba/$smb") or die "Can't $smb settings $!";
1225flock (FILE, 2);
1226
1227if ( $smb eq 'printer')
1228 {while (my ($name, $option) = each %printer){chomp $option;$option =~ s/\r\n/\n/gi;$option =~ s/^\n//gi;$option =~ s/^\r//gi;$option =~ s/^.\n//gi;$option =~ s/^.\r//gi;print FILE "$option\n";}}
1229
1230if ( $smb eq 'shares')
1231 {while (my ($name, $option) = each %shares){chomp $option;$option =~ s/\r\n/\n/gi;$option =~ s/^\n//gi;$option =~ s/^\r//gi;$option =~ s/^.\n//gi;$option =~ s/^.\r//gi;print FILE "$option\n";} }
1232
1233close FILE;
1234
1235if ( -e "/var/ipfire/cups/enable")
1236 {
060ecb12 1237 if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdccups");}
c41c2eb4
CS
1238 else {system("/usr/local/bin/sambactrl smbsafeconfcups");}
1239 }
1240else
1241 {
060ecb12 1242 if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdc");}
c41c2eb4
CS
1243 else{system("/usr/local/bin/sambactrl smbsafeconf");}
1244 }
1245
1246system("/usr/local/bin/sambactrl smbreload");
63d4db83 1247refreshpage();
a4a3e35c 1248}
c41c2eb4 1249
5e773594 1250sub isrunning
32f77a0b
CS
1251 {
1252 my $cmd = $_[0];
1253 my $status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
1254 my $pid = '';
1255 my $testcmd = '';
1256 my $exename;
1257
1258 $cmd =~ /(^[a-z]+)/;
1259 $exename = $1;
1260
1261 if (open(FILE, "/var/run/${cmd}.pid"))
1262 {
1263 $pid = <FILE>; chomp $pid;
1264 close FILE;
1265 if (open(FILE, "/proc/${pid}/status"))
1266 {
1267 while (<FILE>)
1268 {
1269 if (/^Name:\W+(.*)/)
1270 {
1271 $testcmd = $1;
1272 }
1273 }
1274 close FILE;
1275 if ($testcmd =~ /$exename/)
1276 {
1277 $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
1278 }
1279 }
1280 }
1281 return $status;
c41c2eb4 1282 }