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