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