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