]> git.ipfire.org Git - ipfire-2.x.git/blame - html/cgi-bin/samba.cgi
Merge remote-tracking branch 'origin/master' into next
[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 #
725254ef 5# Copyright (C) 2005-2013 IPFire Team <info@ipfire.org> #
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';
9f82cdb1 80$sambasettings{'SRVSTRING'} = 'Samba running on IPFire 2.x';
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 94$sambasettings{'GUESTACCOUNT'} = 'samba';
725254ef 95$sambasettings{'MAPTOGUEST'} = 'Bad User';
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';
94ce2cc1 102$sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=819200 SO_SNDBUF=819200 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';
94ce2cc1 152 $sambasettings{'SRVSTRING'} = 'Samba running on IPFire 2.x';
fa7be659
CS
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 166 $sambasettings{'GUESTACCOUNT'} = 'samba';
725254ef 167 $sambasettings{'MAPTOGUEST'} = 'Bad User';
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';
94ce2cc1 186 $sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=819200 SO_SNDBUF=819200 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
725254ef
AF
430if ( $sambasettings{'MAPTOGUEST'} eq "Never" ) {
431 $sambasettings{'MAPTOGUEST'}="Bad User";
432}
97de2cae 433$selected{'MAPTOGUEST'}{$sambasettings{'MAPTOGUEST'}} = "selected='selected'";
97de2cae 434$selected{'SECURITY'}{$sambasettings{'SECURITY'}} = "selected='selected'";
5e773594
MT
435
436############################################################################################################################
32f77a0b 437################################### Aufbau der HTML Seite fr globale Sambaeinstellungen ###################################
5e773594 438
c9e1c143 439&Header::openbox('100%', 'center', $Lang::tr{'samba'});
5e773594 440print <<END
c41c2eb4
CS
441<br />
442<table width='95%' cellspacing='0'>
32f77a0b
CS
443END
444;
445if ( $message ne "" )
446 {
c9e1c143 447 print "<tr><td colspan='3' align='left'><font color='red'>$message</font>";
32f77a0b
CS
448 }
449
450print <<END
f2fdd0c1 451<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'all services'}</b></td></tr>
32f77a0b
CS
452</table><table width='95%' cellspacing='0'>
453END
454;
455
456my $key = '';
457foreach $key (sort keys %servicenames)
458 {
c9e1c143 459 print "<tr><td align='left' width='40%'>$key</td>";
32f77a0b
CS
460 my $shortname = $servicenames{$key};
461 my $status = &isrunning($shortname);
c9e1c143 462 print "$status</tr>";
32f77a0b
CS
463 }
464
465print <<END
32f77a0b 466</table>
92004c61 467<br />
60124059 468<table width='95%' cellspacing='0'>
60124059 469<tr><td align='left' width='40%' />
a08a5f33
CS
470<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>
471<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>
472<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 473</table>
92004c61 474<br />
32f77a0b
CS
475<form method='post' action='$ENV{'SCRIPT_NAME'}'>
476<table width='95%' cellspacing='0'>
f2fdd0c1 477<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'basic options'}</b></td></tr>
c9e1c143
CS
478<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>
479<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
480<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>
481<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>
482<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
483<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>
484<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
485<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>
486<tr><td align='left' width='40%'>Syslog only</td><td align='left'>on <input type='radio' name='SYSLOGONLY' value='on' $checked{'SYSLOGONLY'}{'on'} />/
a1953287 487 <input type='radio' name='SYSLOGONLY' value='off' $checked{'SYSLOGONLY'}{'off'} /> off</td></tr>
c9e1c143 488<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 489 <input type='radio' name='VPN' value='off' $checked{'VPN'}{'off'} /> off |
f57976de 490 <font size='2' color='$Header::colourovpn'><b> OpenVpn - $ovpnip[0].$ovpnip[1].$ovpnip[2].$ovpnip[3]/$ovpnnetwork[1]</b></font></td></tr>
fa7be659 491<tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='GREEN' value='on' $checked{'GREEN'}{'on'} />/
32f77a0b
CS
492 <input type='radio' name='GREEN' value='off' $checked{'GREEN'}{'off'} /> off |
493 <font size='2' color='$Header::colourgreen'><b> $Lang::tr{'green'} - $netsettings{'GREEN_DEV'}</b></font></td></tr>
494END
495;
496
497if (&Header::blue_used())
498 {
499 print <<END
fa7be659 500 <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='BLUE' value='on' $checked{'BLUE'}{'on'} />/
32f77a0b
CS
501 <input type='radio' name='BLUE' value='off' $checked{'BLUE'}{'off'} /> off |
502 <font size='2' color='$Header::colourblue'><b> $Lang::tr{'wireless'} - $netsettings{'BLUE_DEV'}</b></font></td></tr>
503END
504;
505 }
506
507if (&Header::orange_used())
508 {
509 print <<END
fa7be659 510 <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='ORANGE' value='on' $checked{'ORANGE'}{'on'} />/
32f77a0b
CS
511 <input type='radio' name='ORANGE' value='off' $checked{'ORANGE'}{'off'} /> off |
512 <font size='2' color='$Header::colourorange'><b> $Lang::tr{'dmz'} - $netsettings{'ORANGE_DEV'}</b></font></td></tr>
513END
514;
515 }
516
517print <<END
c9e1c143 518<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 519<tr><td align='left'><br /></td><td></td></tr>
c9f3d846
AF
520<tr><td align='left' width='40%'>Wide links</td><td align='left'>on <input type='radio' name='WIDELINKS' value='on' $checked{'WIDELINKS'}{'on'} />/
521 <input type='radio' name='WIDELINKS' value='off' $checked{'WIDELINKS'}{'off'} /> off</td></tr>
522<tr><td align='left' width='40%'>Unix extension</td><td align='left'>on <input type='radio' name='UNIXEXTENSION' value='on' $checked{'UNIXEXTENSION'}{'on'} />/
523 <input type='radio' name='UNIXEXTENSION' value='off' $checked{'UNIXEXTENSION'}{'off'} /> off</td></tr>
703a8221
CS
524<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'} />/
525 <input type='radio' name='SMB2' value='off' $checked{'SMB2'}{'off'} /> off</td></tr>
c9f3d846 526<tr><td align='left'><br /></td><td></td></tr>
f2fdd0c1 527<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'security options'}</b></td></tr>
c9e1c143 528<tr><td align='left' width='40%'>$Lang::tr{'security'}</td><td align='left'><select name='SECURITY' style="width: 165px">
32f77a0b
CS
529 <option value='share' $selected{'SECURITY'}{'share'}>Share</option>
530 <option value='user' $selected{'SECURITY'}{'user'}>User</option>
531 <option value='domain' $selected{'SECURITY'}{'domain'}>Domain</option>
532 <option value='ADS' $selected{'SECURITY'}{'ADS'}>ADS</option>
533 <option value='server' $selected{'SECURITY'}{'server'}>Server</option>
534 </select></td></tr>
c9e1c143 535<tr><td align='left' width='40%'>$Lang::tr{'map to guest'}</td><td align='left'><select name='MAPTOGUEST' style="width: 165px">
32f77a0b
CS
536 <option value='Bad User' $selected{'MAPTOGUEST'}{'Bad User'}>Bad User</option>
537 <option value='Bad Password' $selected{'MAPTOGUEST'}{'Bad Password'}>Bad Password</option>
538 </select></td></tr>
2a1f6aa7
CS
539END
540;
541#<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'} />/
542# <input type='radio' name='PASSWORDSYNC' value='off' $checked{'PASSWORDSYNC'}{'off'} /> off</td></tr>
543print <<END
fa7be659 544<tr><td align='left'><br /></td><td /></tr>
f2fdd0c1 545<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'network options'}</b></td></tr>
c9e1c143 546<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 547<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 548<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 549<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
550END
551;
c9e1c143 552if ($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 553 print <<END
c9e1c143 554<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 555 <input type='radio' name='WINSSUPPORT' value='off' $checked{'WINSSUPPORT'}{'off'} /> off</td></tr>
32f77a0b
CS
556END
557;
558
559if ($sambasettings{'SECURITY'} eq 'user')
560 {
561 print <<END
c9e1c143 562<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 563 <input type='radio' name='LOCALMASTER' value='off' $checked{'LOCALMASTER'}{'off'} /> off</td></tr>
c9e1c143 564<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 565 <input type='radio' name='DOMAINMASTER' value='off' $checked{'DOMAINMASTER'}{'off'} /> off</td></tr>
c9e1c143 566<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
567 <input type='radio' name='PREFERREDMASTER' value='off' $checked{'PREFERREDMASTER'}{'off'} /> off</td></tr>
568END
569;
570 }
571
572if ($sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'on')
573 {
574 print <<END
575 <tr><td align='left'><br /></td><td></td></tr>
f2fdd0c1 576 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'pdc options'}</b></td></tr>
32f77a0b
CS
577 <tr><td align='left'><br /></td><td></td></tr>
578 <tr><td colspan='2' align='center'><textarea name="PDCOPTIONS" cols="50" rows="15" Wrap="off">$PDCOPTIONS</textarea></td></tr>
579END
c41c2eb4
CS
580;
581 }
582
583 if ( -e "/var/ipfire/cups/enable")
584 {
585 print <<END
586 <tr><td align='left'><br /></td><td></td></tr>
f2fdd0c1 587 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'printing options'}</b></td></tr>
c41c2eb4
CS
588 <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>
589 <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>
590 <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>
591END
32f77a0b
CS
592;
593 }
594
595print <<END
596</table>
92004c61 597<br />
32f77a0b 598<table width='10%' cellspacing='0'>
32f77a0b
CS
599<tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
600 <input type='hidden' name='ACTION' value=$Lang::tr{'save'} />
a08a5f33 601 <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></form></td>
32f77a0b
CS
602<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
603 <input type='hidden' name='ACTION' value='globalreset' />
a08a5f33 604 <input type='image' alt='$Lang::tr{'reset'}' title='$Lang::tr{'reset'}' src='/images/reload.gif' /></form></td>
32f77a0b
CS
605<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
606 <input type='hidden' name='ACTION' value='globalcaption' />
a08a5f33 607 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form></td></tr>
32f77a0b 608</table>
44254afd
MT
609END
610;
32f77a0b 611
44254afd 612if ($sambasettings{'ACTION'} eq 'globalcaption')
32f77a0b
CS
613 {
614 print <<END
92004c61 615 <br />
32f77a0b 616 <table width='95%' cellspacing='0'>
c9e1c143 617 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
60124059 618 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save settings'}</td></tr>
c9e1c143 619 <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'restore settings'}</td></tr>
32f77a0b 620 </table>
5e773594
MT
621END
622;
32f77a0b
CS
623 }
624
5e773594
MT
625&Header::closebox();
626
14cc7eac 627############################################################################################################################
32f77a0b 628########################################## Benutzerverwaltung fr Usersecurity #############################################
14cc7eac 629
1ee8bf5d 630if ($sambasettings{'SECURITY'} eq 'user')
32f77a0b
CS
631 {
632 if ($sambasettings{'DOMAINMASTER'} eq 'off')
633 {
c9e1c143 634 &Header::openbox('100%', 'center', $Lang::tr{'accounting user nonpdc'});
32f77a0b
CS
635 }
636 else
637 {
c9e1c143 638 &Header::openbox('100%', 'center', $Lang::tr{'accounting user pdc'});
32f77a0b
CS
639 }
640 print <<END
d3bea043 641 <a name="$Lang::tr{'accounting'}"></a>
92004c61 642 <br />
32f77a0b 643 <table width='95%' cellspacing='0'>
32f77a0b 644 <tr><td colspan='6' align='left'></td></tr>
f2fdd0c1 645 <tr><td bgcolor='$color{'color20'}' colspan='7' align='left'><b>$Lang::tr{'accounting'}</b></td></tr>
c9e1c143 646 <tr><td align='left'><u>$Lang::tr{'username'}</u></td><td align='left'><u>$Lang::tr{'password'}</u></td>
32f77a0b
CS
647END
648;
5e773594 649
32f77a0b
CS
650 if ($sambasettings{'DOMAINMASTER'} eq 'off')
651 {
652 print "<td></td>";
653 }
654 else
655 {
92004c61 656 print "<td align='left'><u>$Lang::tr{'type'}</u></td>";
32f77a0b
CS
657 }
658
92004c61 659 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 660 system('/usr/local/bin/sambactrl readsmbpasswd');
c41c2eb4 661 open(FILE, "<${General::swroot}/samba/private/smbpasswd") or die "Can't read user file: $!";
32f77a0b
CS
662 @user = <FILE>;
663 close(FILE);
664 system('/usr/local/bin/sambactrl locksmbpasswd');
a28fdc01
CS
665
666 my $lines = 0;
667
32f77a0b
CS
668 foreach $userentry (sort @user)
669 {
670 @userline = split( /\:/, $userentry );
a28fdc01
CS
671 if ($lines % 2) {print "<tr bgcolor='$color{'color20'}'>";} else {print "<tr bgcolor='$color{'color22'}'>";}
672 print "<td align='left'>$userline[0]</td><td align='left'>";
32f77a0b
CS
673 if ($userline[4] =~ /N/)
674 {
c9e1c143 675 print "$Lang::tr{'not set'}</td><td align='left'>";
32f77a0b
CS
676 }
677 else
678 {
c9e1c143 679 print "$Lang::tr{'set'}</td><td align='left'>";
32f77a0b
CS
680 }
681
682 if ($sambasettings{'DOMAINMASTER'} eq 'off')
683 {
fa7be659 684 print "</td><td align='left'>";
32f77a0b
CS
685 }
686 else
687 {
688 if ($userline[0] =~ /\$/)
689 {
71dfc4b7 690 print "$Lang::tr{'pc'}</td><td align='left'>";
32f77a0b
CS
691 }
692 else
693 {
c9e1c143 694 print "$Lang::tr{'user'}</td><td align='left'>";
32f77a0b
CS
695 }
696 }
697
698 if ($userline[4] =~ /D/)
699 {
700 print <<END
92004c61 701 $Lang::tr{'inactive'}</td>
19f5a6cc 702 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b
CS
703 <input type='hidden' name='NAME' value='$userline[0]' />
704 <input type='hidden' name='ACTION' value='smbuserenable' />
25943d3b 705 <input type='image' alt='$Lang::tr{'activate'}' title='$Lang::tr{'activate'}' src='/images/off.gif' />
32f77a0b
CS
706 </form></td>
707END
708;
709 }
710 else
711 {
712 print <<END
92004c61 713 $Lang::tr{'active'}</td>
19f5a6cc 714 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b
CS
715 <input type='hidden' name='NAME' value='$userline[0]' />
716 <input type='hidden' name='ACTION' value='smbuserdisable' />
25943d3b 717 <input type='image' alt='$Lang::tr{'deactivate'}' title='$Lang::tr{'deactivate'}' src='/images/on.gif' />
32f77a0b
CS
718 </form></td>
719END
720;
721 }
722
723 if ($userline[0] =~ /\$/)
724 {
725 print "<td></td>";
726 }
727 else
728 {
729 print <<END
19f5a6cc 730 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b
CS
731 <input type='hidden' name='NAME' value='$userline[0]' />
732 <input type='hidden' name='ACTION' value='userchangepw' />
a08a5f33 733 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
32f77a0b
CS
734 </form></td>
735END
736;
737 }
738
fa7be659
CS
739 if ($sambasettings{'DOMAINMASTER'} eq 'on' && $userline[0] =~ /\$/)
740 {
741 print <<END
19f5a6cc 742 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
fa7be659
CS
743 <input type='hidden' name='NAME' value='$userline[0]' />
744 <input type='hidden' name='ACTION' value='userdelete' />
a08a5f33 745 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/network-error.png' />
fa7be659
CS
746 </form></td></tr>
747END
748;
749 }
750 else
751 {
752 print <<END
19f5a6cc 753 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
fa7be659
CS
754 <input type='hidden' name='NAME' value='$userline[0]' />
755 <input type='hidden' name='ACTION' value='userdelete' />
a08a5f33 756 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-option-remove.png' />
fa7be659 757 </form></td></tr>
32f77a0b
CS
758END
759;
fa7be659 760 }
a28fdc01 761 $lines++;
32f77a0b
CS
762 }
763 print <<END
764 </table>
92004c61 765 <br />
32f77a0b 766 <table width='10%' cellspacing='0'>
19f5a6cc 767 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b 768 <input type='hidden' name='ACTION' value='useradd' />
a08a5f33 769 <input type='image' alt='$Lang::tr{'add user'}' title='$Lang::tr{'add user'}' src='/images/user-option-add.png' /></form></td>
5e773594
MT
770END
771;
1ee8bf5d 772
32f77a0b
CS
773 if ($sambasettings{'DOMAINMASTER'} eq 'on')
774 {
775 print <<END
19f5a6cc 776 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b 777 <input type='hidden' name='ACTION' value='pcadd' />
a08a5f33 778 <input type='image' alt='$Lang::tr{'pc add'}' title='$Lang::tr{'pc add'}' src='/images/network.png' /></form>
32f77a0b
CS
779END
780;
781 }
782 print <<END
19f5a6cc 783 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b 784 <input type='hidden' name='ACTION' value='usercaption' />
a08a5f33 785 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form>
94819213 786 </td></tr>
32f77a0b
CS
787 </table>
788END
789;
44254afd 790
32f77a0b
CS
791 if ($sambasettings{'ACTION'} eq 'usercaption')
792 {
793 print <<END
92004c61 794 <br />
32f77a0b 795 <table width='95%' cellspacing='0'>
c9e1c143
CS
796 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
797 <tr><td align='right' width='33%'><img src='/images/user-option-add.png' /></td><td align='left'>$Lang::tr{'add user'}</td></tr>
115340d2 798 <tr><td align='right' width='33%'><img src='/images/network.png' /></td><td align='left'>$Lang::tr{'pc add'}</td></tr>
c9e1c143
CS
799 <tr><td align='right' width='33%'><img src='/images/user-option-remove.png' /></td><td align='left'>$Lang::tr{'delete user'}</td></tr>
800 <tr><td align='right' width='33%'><img src='/images/network-error.png' /></td><td align='left'>$Lang::tr{'delete pc'}</td></tr>
25943d3b
CS
801 <tr><td align='right' width='33%'><img src='/images/off.gif' /></td><td align='left'>$Lang::tr{'activate user'}</td></tr>
802 <tr><td align='right' width='33%'><img src='/images/on.gif' /></td><td align='left'>$Lang::tr{'deactivate user'}</td></tr>
c9e1c143 803 <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'change passwords'}</td></tr>
60124059 804 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr>
32f77a0b 805 </table>
1ee8bf5d
MT
806END
807;
32f77a0b
CS
808 }
809
810 if ($sambasettings{'ACTION'} eq 'userchangepw')
811 {
812 my $username = "$sambasettings{'NAME'}";
813 my $password = 'samba';
814 print <<END
92004c61 815 <br />
19f5a6cc 816 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b 817 <table width='95%' cellspacing='0'>
f2fdd0c1 818 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'change passwords'}</b></td></tr>
153cf640 819 <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' readonly='readonly' /></td></tr>
c9e1c143 820 <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr>
32f77a0b 821 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbchangepw' />
f8aa0679 822 <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></td></tr>
32f77a0b 823 </table>
94819213 824 </form>
1ee8bf5d
MT
825END
826;
32f77a0b
CS
827 }
828
829 if ($sambasettings{'ACTION'} eq 'useradd')
830 {
831 my $username = "user";
832 my $password = "samba";
833 chomp $username;
834 $username=~s/\s//g;
835 chomp $password;
836 $password=~s/\s//g;
837 print <<END
92004c61 838 <br />
19f5a6cc 839 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b 840 <table width='95%' cellspacing='0'>
f2fdd0c1 841 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add user'}</b></td></tr>
c9e1c143
CS
842 <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' /></td></tr>
843 <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr>
844 <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambauser' size='30' /></td></tr>
845 <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr>
32f77a0b 846 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbuseradd' />
f8aa0679 847 <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></td></tr>
32f77a0b 848 </table>
94819213 849 </form>
32f77a0b
CS
850END
851;
852 }
853
854 if ($sambasettings{'ACTION'} eq 'pcadd')
855 {
856 my $pcname = "client\$";
857 chomp $pcname;
858 $pcname=~s/\s//g;
859 print <<END
92004c61 860 <br />
19f5a6cc 861 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
32f77a0b 862 <table width='95%' cellspacing='0'>
f2fdd0c1 863 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'pc add'}</b></td></tr>
c9e1c143
CS
864 <tr><td align='left'>$Lang::tr{'client'}</td><td><input type='text' name='PCNAME' value='$pcname' size='30' /></td></tr>
865 <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambawks' size='30' /></td></tr>
866 <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr>
32f77a0b 867 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbpcadd' />
f8aa0679 868 <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></td></tr>
32f77a0b 869 </table>
94819213 870 </form>
32f77a0b
CS
871END
872;
873 }
97de2cae
MT
874
875&Header::closebox();
1ee8bf5d 876}
14cc7eac
MT
877
878############################################################################################################################
879############################################### Verwalten von Freigaben ####################################################
fa7be659 880
c9e1c143 881&Header::openbox('100%', 'center', $Lang::tr{'shares'});
97de2cae 882
c41c2eb4
CS
883my %shares = config("${General::swroot}/samba/shares");
884
885
1ee8bf5d 886print <<END
d3bea043 887<a name="$Lang::tr{'manage shares'}"></a>
92004c61 888<br />
961f3dbc
AM
889<table width='95%' cellspacing='0' class='tbl'>
890<tr><th bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'manage shares'}</b></th></tr>
891<tr><th align='left'><u>$Lang::tr{'sharename'}</u></th><th colspan='2' width="5%" align='center'><u>$Lang::tr{'options'}</u></th></tr>
1ee8bf5d
MT
892END
893;
14cc7eac 894
c41c2eb4 895my @Shares = keys(%shares);
a28fdc01 896my $lines = 0;
961f3dbc 897my $col="";
c41c2eb4 898foreach my $shareentry (sort @Shares)
32f77a0b 899 {
c41c2eb4 900 chomp $shareentry;
961f3dbc
AM
901 if ($lines % 2) {
902 print "<tr>";
903 $col="bgcolor='$color{'color20'}'";
904 } else {
905 print "<tr>";
906 $col="bgcolor='$color{'color22'}'";
907 }
32f77a0b 908 print <<END
961f3dbc
AM
909 <td align='left' $col>$shareentry</td>
910 <td $col><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
32f77a0b
CS
911 <input type='hidden' name='NAME' value='$shareentry' />
912 <input type='hidden' name='ACTION' value='sharechange' />
a08a5f33 913 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
32f77a0b 914 </form></td>
961f3dbc 915 <td $col><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
32f77a0b
CS
916 <input type='hidden' name='NAME' value='$shareentry' />
917 <input type='hidden' name='ACTION' value='smbsharedel' />
a08a5f33 918 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' />
94819213 919 </form></td></tr>
32f77a0b
CS
920END
921;
a28fdc01 922 $lines++;
32f77a0b
CS
923 }
924
925print <<END
926</table>
92004c61 927<br />
32f77a0b 928<table width='10%' cellspacing='0'>
19f5a6cc 929<tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
94819213 930 <input type='hidden' name='ACTION' value='shareadd' />
a08a5f33 931 <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/list-add.png' />
32f77a0b 932 </form></td>
19f5a6cc 933 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
94819213 934 <input type='hidden' name='ACTION' value='sharesreset' />
a08a5f33 935 <input type='image' alt='$Lang::tr{'reset'}' title='$Lang::tr{'reset'}' src='/images/reload.gif' />
32f77a0b 936 </form></td>
19f5a6cc 937 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
88932936 938 <input type='hidden' name='ACTION' value='sharecaption' />
a08a5f33 939 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' />
88932936
CS
940 </form></td>
941</tr>
32f77a0b 942</table>
1ee8bf5d
MT
943END
944;
32f77a0b 945
1ee8bf5d 946if ($sambasettings{'ACTION'} eq 'sharecaption')
32f77a0b
CS
947 {
948 print <<END
92004c61 949 <br />
32f77a0b 950 <table width='95%' cellspacing='0'>
92004c61 951 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
60124059 952 <tr><td align='right' width='33%'><img src='/images/list-add.png' /></td><td align='left'>$Lang::tr{'add share'}</td></tr>
c9e1c143 953 <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'edit share'}</td></tr>
60124059 954 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr>
c9e1c143 955 <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'reset shares'}</td></tr>
60124059 956 <tr><td align='right' width='33%'><img src='/images/user-trash.png' /></td><td align='left'>$Lang::tr{'delete share'}</td></tr>
32f77a0b 957 </table>
1ee8bf5d
MT
958END
959;
32f77a0b 960 }
97de2cae 961
1ee8bf5d 962if ($sambasettings{'ACTION'} eq 'shareadd' || $sambasettings{'ACTION'} eq 'optioncaption' )
32f77a0b
CS
963 {
964 print <<END
92004c61 965 <br />
32f77a0b 966 <table width='95%' cellspacing='0'>
f2fdd0c1 967 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add share'}</b></td></tr>
32f77a0b 968 <tr><td colspan='2' align='center'></td></tr>
88932936 969 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}
c41c2eb4 970 <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 971 <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 972 </table>
92004c61 973 <br />
32f77a0b 974 <table width='10%' cellspacing='0'>
94819213 975 <tr><td align='center'><input type='hidden' name='ACTION' value='smbshareadd' />
a08a5f33 976 <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/media-floppy.png' /></td></tr></form>
32f77a0b 977 </table>
5e773594
MT
978END
979;
32f77a0b 980 }
5e773594 981
1ee8bf5d 982if ($sambasettings{'ACTION'} eq 'sharechange' || $sambasettings{'ACTION'} eq 'optioncaption2' )
32f77a0b 983 {
c41c2eb4 984 my $shareoption = $shares{$sambasettings{'NAME'}};
32f77a0b 985 print <<END
92004c61 986 <br />
32f77a0b 987 <table width='95%' cellspacing='0'>
f2fdd0c1 988 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'edit share'}</b></td></tr>
32f77a0b 989 <tr><td colspan='2' align='center'></td></tr>
c41c2eb4 990 <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 991 <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 992 </table>
92004c61 993 <br />
32f77a0b 994 <table width='10%' cellspacing='0'>
94819213 995 <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' />
a08a5f33 996 <input type='image' alt='$Lang::tr{'change share'}' title='$Lang::tr{'change share'}' src='/images/media-floppy.png' />
fa7be659 997 <input type='hidden' name='ACTION' value='smbsharechange' /></form></td></tr>
32f77a0b 998 </table>
1ee8bf5d
MT
999END
1000;
32f77a0b 1001 }
5e773594 1002
c41c2eb4
CS
1003if ($sambasettings{'ACTION'} eq 'sharesresetyes')
1004 {
1005 system('/usr/local/bin/sambactrl smbsharesreset');
1006 my $shares = config("${General::swroot}/samba/shares");
1007 system("/usr/local/bin/sambactrl smbreload");
1008 }
1009if ($sambasettings{'ACTION'} eq 'smbshareadd')
1010 {
1011 $shares{'xvx'}= "$sambasettings{'SHAREOPTION'}";
1012 save("shares");
1013 my $shares = config("${General::swroot}/samba/shares");
1014 }
1015if ($sambasettings{'ACTION'} eq 'smbsharedel')
1016 {
1017 delete $shares{$sambasettings{'NAME'}};
1018 save("shares");
1019 my %shares = config("${General::swroot}/samba/shares");
1020 }
1021if ($sambasettings{'ACTION'} eq 'smbsharechange')
1022 {
1023 $shares{$sambasettings{'NAME'}} = $sambasettings{'SHAREOPTION'};
1024 save("shares");
1025 my %shares = config("${General::swroot}/samba/shares");
1026 }
1027
1028&Header::closebox();
1029
1030############################################################################################################################
1031################################################ Verwalten von Druckern ####################################################
1032
1033my %printer = config("${General::swroot}/samba/printer");
1034
1035if ( -e "/var/ipfire/cups/enable")
1036{
1037&Header::openbox('100%', 'center', $Lang::tr{'printer'});
1038
1039my @Printers = keys(%printer);
1040print <<END
d3bea043 1041<a name="$Lang::tr{'manage printers'}"></a>
c41c2eb4
CS
1042<br />
1043<table width='95%' cellspacing='0'>
f2fdd0c1 1044<tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'manage printers'}</b>
c41c2eb4
CS
1045<tr><td align='left'><u>$Lang::tr{'printername'}</u></td><td colspan='2' width="5%" align='center'><u>$Lang::tr{'options'}</u></td></tr>
1046END
1047;
1048foreach my $printerentry (sort @Printers)
1049 {
1050 chomp $printerentry;
1051 print <<END
1052 <tr><td align='left'>$printerentry</td>
19f5a6cc 1053 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
c41c2eb4
CS
1054 <input type='hidden' name='NAME' value='$printerentry' />
1055 <input type='hidden' name='ACTION' value='printerchange' />
a08a5f33 1056 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
c41c2eb4 1057 </form></td>
19f5a6cc 1058 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
c41c2eb4
CS
1059 <input type='hidden' name='NAME' value='$printerentry' />
1060 <input type='hidden' name='ACTION' value='smbprinterdel' />
a08a5f33 1061 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' />
c41c2eb4
CS
1062 </form></td></tr>
1063END
1064;
1065 }
1066print <<END
1067</table>
1068<br />
1069<table width='10%' cellspacing='0'>
19f5a6cc 1070<tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
c41c2eb4 1071 <input type='hidden' name='ACTION' value='printeradd' />
a08a5f33 1072 <input type='image' alt='$Lang::tr{'add printer'}' title='$Lang::tr{'add printer'}' src='/images/list-add.png' />
c41c2eb4 1073 </form></td>
19f5a6cc 1074 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
c41c2eb4 1075 <input type='hidden' name='ACTION' value='printereset' />
a08a5f33 1076 <input type='image' alt='$Lang::tr{'reset'}' title='$Lang::tr{'reset'}' src='/images/reload.gif' />
c41c2eb4 1077 </form></td>
19f5a6cc 1078 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
c41c2eb4 1079 <input type='hidden' name='ACTION' value='printercaption' />
a08a5f33 1080 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' />
c41c2eb4
CS
1081 </form></td>
1082</tr>
1083</table>
1084END
1085;
1086
1087if ($sambasettings{'ACTION'} eq 'printeradd' || $sambasettings{'ACTION'} eq 'printercaption' )
1088 {
1089 print <<END
c41c2eb4
CS
1090 <br />
1091 <table width='95%' cellspacing='0'>
f2fdd0c1 1092 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add printer'}</b></td></tr>
c41c2eb4
CS
1093 <tr><td colspan='2' align='center'></td></tr>
1094 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}
1095 <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 1096 <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
1097 </table>
1098 <br />
1099 <table width='10%' cellspacing='0'>
1100 <tr><td align='center'><input type='hidden' name='ACTION' value='smbprinteradd' />
a08a5f33 1101 <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/media-floppy.png' /></td></tr>
c41c2eb4
CS
1102 </table>
1103 </form>
1104END
1105;
1106 }
1107
1108if ($sambasettings{'ACTION'} eq 'printerchange' || $sambasettings{'ACTION'} eq 'printercaption2' )
1109 {
1110 my $printeroption = $printer{$sambasettings{'NAME'}};
1111 print <<END
c41c2eb4
CS
1112 <br />
1113 <table width='95%' cellspacing='0'>
f2fdd0c1 1114 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'edit printer'}</b></td></tr>
c41c2eb4
CS
1115 <tr><td colspan='2' align='center'></td></tr>
1116 <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 1117 <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
1118 </table>
1119 <br />
1120 <table width='10%' cellspacing='0'>
1121 <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' />
a08a5f33 1122 <input type='image' alt='$Lang::tr{'change share'}' title='$Lang::tr{'change share'}' src='/images/media-floppy.png' />
c41c2eb4
CS
1123 <input type='hidden' name='ACTION' value='smbprinterchange' /></form></td></tr>
1124 </table>
1125END
1126;
1127 }
1128
1129if ($sambasettings{'ACTION'} eq 'smbprinteradd')
1130 {
1131 $printer{'xvx'}= "$sambasettings{'PRINTEROPTION'}";
1132 save("printer");
1133 my %printer = config("${General::swroot}/samba/printer");
1134 }
1135
1136if ($sambasettings{'ACTION'} eq 'smbprinterdel')
1137 {
1138 delete $printer{$sambasettings{'NAME'}};
1139 save("printer");
1140 my %printer = config("${General::swroot}/samba/printer");
1141 }
1142
1143if ($sambasettings{'ACTION'} eq 'smbprinterchange')
1144 {
1145 $printer{$sambasettings{'NAME'}} = $sambasettings{'PRINTEROPTION'};
1146 save("printer");
1147 my %printer = config("${General::swroot}/samba/printer");
1148 }
1149
32f77a0b 1150&Header::closebox();
c41c2eb4 1151}
32f77a0b
CS
1152
1153############################################################################################################################
1154############################################### Anzeige des Sambastatus ####################################################
1155
1156&Header::openbox('100%', 'center', 'Status');
1157
1158print <<END
92004c61 1159<br />
32f77a0b 1160<table width='95%' cellspacing='0'>
f2fdd0c1 1161<tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'samba status'}</b></td></tr>
fa7be659
CS
1162<tr><td align='left'>$Status</td></tr>
1163</table>
1164END
1165;
1166&Header::closebox();
1167
1168############################################################################################################################
c41c2eb4 1169############################################### Anzeige der Sambalogs ######################################################
fa7be659
CS
1170
1171
1172if ($sambasettings{'ACTION'} eq 'showlog')
1173{
c41c2eb4 1174$Log = qx(tail -n $sambasettings{'LOGLINES'} /var/log/samba/$sambasettings{'LOG'});
fa7be659
CS
1175$Log=~s/\n/<br \/>/g;
1176}
1177
c9e1c143 1178&Header::openbox('100%', 'center', $Lang::tr{'log'});
fa7be659
CS
1179
1180print <<END
d3bea043 1181<a name="$Lang::tr{'log view'}"></a>
92004c61 1182<br />
19f5a6cc 1183<form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'log view'}'>
fa7be659 1184<table width='95%' cellspacing='0'>
f2fdd0c1 1185<tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'log view'}</b></td></tr>
fa7be659
CS
1186<tr><td colspan='3' align='left'><br /></td></tr>
1187<tr><td align='left'><select name='LOG' style="width: 200px">
1188END
1189;
1190foreach my $log (@Logs) {chomp $log;print"<option value='$log'>$log</option>";}
1191print <<END
1192
c9e1c143 1193</select></td><td align='left'>$Lang::tr{'show last x lines'}<input type='text' name='LOGLINES' value='$LOGLINES' size="3" /></td>
a08a5f33 1194 <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
1195<tr><td colspan='3' align='left'><br /></td></tr>
1196<tr><td colspan='3' align='left'><font size=2>$Log</font></td></tr>
1197<tr><td colspan='3' align='left'><br /></td></tr>
1198<tr><td colspan='3' align='center'>$sambasettings{'LOG'}</td></tr>
32f77a0b 1199</table>
fa7be659 1200</form>
32f77a0b
CS
1201END
1202;
1ee8bf5d 1203&Header::closebox();
5e773594
MT
1204&Header::closebigbox();
1205&Header::closepage();
1206
1207############################################################################################################################
fa7be659 1208############################################ Subfunktion fr Sambadienste ###################################################
5e773594 1209
c41c2eb4
CS
1210sub config
1211{
1212my $file = shift;
1213my @allarray = `grep -n '^\\[' $file`;
1214my @linesarray = ();
1215my @namearray = ();
1216my %hash = ();
1217my $options = ();
1218my $EOF = qx(cat $file | wc -l);
1219foreach my $allarrayentry (@allarray)
1220 {
1221 my @allarrayline = split( /\:/, $allarrayentry );
1222 push(@linesarray,$allarrayline[0]);$allarrayline[1]=~s/\[//g;$allarrayline[1]=~s/\]//g;push(@namearray,$allarrayline[1]);
1223 }
1224 for(my $i = 0; $i <= $#namearray; $i++)
1225 {
1226 chomp $namearray[$i];
1227 $namearray[$i]=~s/\[//g;$namearray[$i]=~s/\]//g;
1228 if ( $i eq $#namearray )
1229 {
1230 my $lineend = $EOF-$linesarray[$i]+1;
1231 $options=qx(tail -$lineend $file);
1232 }
1233 else
1234 {
1235 my $linestart = $EOF-$linesarray[$i]+1;
1236 my $lineend = $linesarray[$i+1]-$linesarray[$i];
1237 $options=qx(tail -$linestart $file | head -$lineend);
1238 }
1239 $hash{$namearray[$i]} = "$options";
1e482cb6 1240 #print"<pre>$namearray[$i]\n$options\n</pre>"; # enable only for debuging
c41c2eb4
CS
1241 }
1242return(%hash);
1243}
1244
1245sub save
1246{
1247my $smb = shift;
1248open (FILE, ">${General::swroot}/samba/$smb") or die "Can't $smb settings $!";
1249flock (FILE, 2);
1250
1251if ( $smb eq 'printer')
1252 {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";}}
1253
1254if ( $smb eq 'shares')
1255 {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";} }
1256
1257close FILE;
1258
1259if ( -e "/var/ipfire/cups/enable")
1260 {
060ecb12 1261 if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdccups");}
c41c2eb4
CS
1262 else {system("/usr/local/bin/sambactrl smbsafeconfcups");}
1263 }
1264else
1265 {
060ecb12 1266 if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdc");}
c41c2eb4
CS
1267 else{system("/usr/local/bin/sambactrl smbsafeconf");}
1268 }
1269
1270system("/usr/local/bin/sambactrl smbreload");
63d4db83 1271refreshpage();
a4a3e35c 1272}
c41c2eb4 1273
5e773594 1274sub isrunning
32f77a0b
CS
1275 {
1276 my $cmd = $_[0];
1277 my $status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
1278 my $pid = '';
1279 my $testcmd = '';
1280 my $exename;
1281
1282 $cmd =~ /(^[a-z]+)/;
1283 $exename = $1;
1284
1285 if (open(FILE, "/var/run/${cmd}.pid"))
1286 {
1287 $pid = <FILE>; chomp $pid;
1288 close FILE;
1289 if (open(FILE, "/proc/${pid}/status"))
1290 {
1291 while (<FILE>)
1292 {
1293 if (/^Name:\W+(.*)/)
1294 {
1295 $testcmd = $1;
1296 }
1297 }
1298 close FILE;
1299 if ($testcmd =~ /$exename/)
1300 {
1301 $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
1302 }
1303 }
1304 }
1305 return $status;
c41c2eb4 1306 }