samba: Add GUI functionality to join a domain.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / samba.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 #                                                                             #
4 # IPFire.org - A linux based firewall                                         #
5 # Copyright (C) 2005-2013  IPFire Team  <info@ipfire.org>                     #
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 ###############################################################################
21
22 use strict;
23 # enable only the following on debugging purpose
24 #use warnings;
25 #use CGI::Carp 'fatalsToBrowser';
26
27 require '/var/ipfire/general-functions.pl';
28 require "${General::swroot}/lang.pl";
29 require "${General::swroot}/header.pl";
30
31 my %sambasettings = ();
32 my %cgisettings = ();
33 my %checked = ();
34 my %netsettings = ();
35 my %ovpnsettings = ();
36 my %color = ();
37 my %mainsettings = ();
38 my $message = "";
39 my $errormessage = "";
40
41 my @Logs = qx(ls /var/log/samba/);
42 my $Log =$Lang::tr{'no log selected'};
43
44 my $Status = qx(/usr/local/bin/sambactrl smbstatus);
45 $Status=~s/\n/<br \/>/g;
46
47 my $userentry = "";
48 my @user = ();
49 my @userline = ();
50 my $userfile = "${General::swroot}/samba/private/smbpasswd";
51 my %selected= () ;
52
53 my $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";
54 my $defaultprinter= "[Printer]\ncomment = Printer public\npath = /var/spool/cups\nprinting = sysvn\nprintcap = lpstat\npublic = yes\nwritable = no\nprintable = yes";
55 my %printer = ();
56 my %shares = ();
57
58 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
59 &General::readhash("${General::swroot}/ovpn/settings", \%ovpnsettings);
60 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
61 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
62
63 my @ovpnnetwork = split(/\//,$ovpnsettings{'DOVPN_SUBNET'});
64 my @ovpnip      = split(/\./,$ovpnnetwork[0]);
65 $ovpnip[3]=$ovpnip[3]+1;
66
67 ############################################################################################################################
68 ############################################# Samba Dienste fr Statusberprfung ##########################################
69
70 my %servicenames = ('SMB Daemon' => 'smbd', 'NetBIOS Nameserver' => 'nmbd', 'Winbind Daemon' => 'winbindd');
71
72 &Header::showhttpheaders();
73
74 ############################################################################################################################
75 #################################### Initialisierung von Samba Variablen fr global Settings ###############################
76
77 $sambasettings{'WORKGRP'} = 'homeip.net';
78 $sambasettings{'NETBIOSNAME'} = 'IPFire';
79 $sambasettings{'SRVSTRING'} = 'Samba running on IPFire 2.x';
80 $sambasettings{'INTERFACES'} = '';
81 $sambasettings{'SECURITY'} = 'share';
82 $sambasettings{'OSLEVEL'} = '33';
83 $sambasettings{'GREEN'} = 'on';
84 $sambasettings{'BLUE'} = 'off';
85 $sambasettings{'ORANGE'} = 'off';
86 $sambasettings{'VPN'} = 'off';
87 $sambasettings{'WINSSRV'} = '';
88 $sambasettings{'WINSSUPPORT'} = 'on';
89 $sambasettings{'REMOTEANNOUNCE'} = '';
90 $sambasettings{'REMOTESYNC'} = '';
91 $sambasettings{'PASSWORDSYNC'} = 'off';
92 $sambasettings{'OTHERINTERFACES'} = '127.0.0.1';
93 $sambasettings{'GUESTACCOUNT'} = 'samba';
94 $sambasettings{'MAPTOGUEST'} = 'Bad User';
95 $sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 winbind:2';
96 $sambasettings{'SYSLOGLEVEL'} = '1';
97 $sambasettings{'SYSLOGONLY'} = 'on';
98 $sambasettings{'DOSCHARSET'} = 'CP850';
99 $sambasettings{'UNIXCHARSET'} = 'UTF8';
100 $sambasettings{'DISPLAYCHARSET'} = 'CP850';
101 $sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=819200 SO_SNDBUF=819200 SO_KEEPALIVE';
102 $sambasettings{'WIDELINKS'} = 'on';
103 $sambasettings{'UNIXEXTENSION'} = 'off';
104 $sambasettings{'SMB2'} = 'off';
105 ### Values that have to be initialized
106 $sambasettings{'ACTION'} = '';
107 ### Samba CUPS Variablen
108 $sambasettings{'LOADPRINTERS'} = 'Yes';
109 $sambasettings{'PRINTING'} = 'cups';
110 $sambasettings{'PRINTCAPNAME'} = 'cups';
111 my $LOGLINES = '50';
112
113 ################################################## Samba PDC Variablen #####################################################
114
115 $sambasettings{'LOCALMASTER'} = 'off';
116 $sambasettings{'DOMAINMASTER'} = 'off';
117 $sambasettings{'PREFERREDMASTER'} = 'off';
118 my $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`;
119
120
121 ############################################################################################################################
122
123 &General::readhash("${General::swroot}/samba/settings", \%sambasettings);
124 &Header::getcgihash(\%sambasettings);
125
126 sub 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();}
127
128 if (($sambasettings{'WIDELINKS'} eq 'on') & ($sambasettings{'UNIXEXTENSION'} eq 'on'))
129   {$errormessage = "$errormessage<br />Don't enable 'Wide links' and 'Unix extension' at the same time"; }
130
131 &Header::openpage('Samba', 1, '');
132 &Header::openbigbox('100%', 'left', '', $errormessage);
133
134 ############################################################################################################################
135 ############################################# Samba Rootskript aufrufe fr SU-Actions #######################################
136
137 if ($sambasettings{'ACTION'} eq 'smbuserdisable'){system("/usr/local/bin/sambactrl smbuserdisable $sambasettings{'NAME'}");refreshpage();}
138 if ($sambasettings{'ACTION'} eq 'smbuserenable'){system("/usr/local/bin/sambactrl smbuserenable $sambasettings{'NAME'}");refreshpage();}
139 if ($sambasettings{'ACTION'} eq 'smbuseradd'){system("/usr/local/bin/sambactrl smbuseradd $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");refreshpage();}
140 if ($sambasettings{'ACTION'} eq 'smbpcadd'){system("/usr/local/bin/sambactrl smbpcadd $sambasettings{'PCNAME'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");refreshpage();}
141 if ($sambasettings{'ACTION'} eq 'smbchangepw'){system("/usr/local/bin/sambactrl smbchangepw $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'}");refreshpage();}
142 if ($sambasettings{'ACTION'} eq 'smbrestart'){system("/usr/local/bin/sambactrl smbrestart");refreshpage();}
143 if ($sambasettings{'ACTION'} eq 'smbstart'){system("/usr/local/bin/sambactrl smbstart");refreshpage();}
144 if ($sambasettings{'ACTION'} eq 'smbstop'){system("/usr/local/bin/sambactrl smbstop");refreshpage();}
145 if ($sambasettings{'ACTION'} eq 'smbreload'){system("/usr/local/bin/sambactrl smbreload");refreshpage();}
146 if ($sambasettings{'ACTION'} eq 'globalresetyes')
147         {
148         system("/usr/local/bin/sambactrl smbglobalreset");
149         $sambasettings{'WORKGRP'} = 'homeip.net';
150         $sambasettings{'NETBIOSNAME'} = 'IPFire';
151         $sambasettings{'SRVSTRING'} = 'Samba running on IPFire 2.x';
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'} = '';
162         $sambasettings{'REMOTESYNC'} = '';
163         $sambasettings{'PASSWORDSYNC'} = 'off';
164         $sambasettings{'OTHERINTERFACES'} = '127.0.0.1';
165         $sambasettings{'GUESTACCOUNT'} = 'samba';
166         $sambasettings{'MAPTOGUEST'} = 'Bad User';
167         $sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 winbind:2';
168         $sambasettings{'SYSLOGLEVEL'} = '1';
169         $sambasettings{'SYSLOGONLY'} = 'on';
170         $sambasettings{'DOSCHARSET'} = 'CP850';
171         $sambasettings{'UNIXCHARSET'} = 'UTF8';
172         $sambasettings{'DISPLAYCHARSET'} = 'CP850';
173 ### Samba CUPS Variablen
174         $sambasettings{'LOADPRINTERS'} = 'Yes';
175         $sambasettings{'PRINTING'} = 'cups';
176         $sambasettings{'PRINTCAPNAME'} = 'cups';
177         $sambasettings{'PRINTERNAME'} = 'Printer';
178 ### Values that have to be initialized
179         $sambasettings{'WIDELINKS'} = 'on';
180         $sambasettings{'UNIXEXTENSION'} = 'off';
181         $sambasettings{'ACTION'} = '';
182         $sambasettings{'LOCALMASTER'} = 'off';
183         $sambasettings{'DOMAINMASTER'} = 'off';
184         $sambasettings{'PREFERREDMASTER'} = 'off';
185         $sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=819200 SO_SNDBUF=819200 SO_KEEPALIVE';
186         $sambasettings{'WIDELINKS'} = 'on';
187         $sambasettings{'UNIXEXTENSION'} = 'off';
188         $sambasettings{'SMB2'} = 'off';
189         $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`;
190         system("/usr/local/bin/sambactrl smbreload");
191         refreshpage();
192         }
193
194 if ($sambasettings{'ACTION'} eq 'join') {
195         $message .= &joindomain($sambasettings{'USERNAME'}, $sambasettings{'PASSWORD'});
196 }
197
198 ############################################################################################################################
199 ################################################ Sicherheitsabfrage für den Reset ##########################################
200
201 if ($sambasettings{'ACTION'} eq 'globalreset')
202         {
203         print <<END
204         <br />
205         <table width='95%' cellspacing='0'>
206         <tr><td bgcolor='$color{'color20'}' colspan='3' align='center'><b>$Lang::tr{'resetglobals'}</b>
207         <tr><td align='right' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
208                                          $Lang::tr{'yes'} <input type='image' alt='$Lang::tr{'yes'}' title='$Lang::tr{'yes'}' src='/images/edit-redo.png' />
209                                         <input type='hidden' name='ACTION' value='globalresetyes' /></form></td>
210                         <td align='left'  width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
211                                         <input type='image' alt='$Lang::tr{'no'}' title='$Lang::tr{'no'}' src='/images/dialog-error.png' /> $Lang::tr{'no'} 
212                                         <input type='hidden' name='ACTION' value='cancel' /></form></td>
213         </tr>
214         </table>
215 END
216 ;
217 }
218
219 if ($sambasettings{'ACTION'} eq 'sharesreset')
220         {
221         print <<END
222         <br />
223         <table width='95%' cellspacing='0'>
224         <tr><td bgcolor='$color{'color20'}' colspan='3' align='center'><b>$Lang::tr{'resetshares'}</b>
225         <tr><td align='right'  width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
226                                          $Lang::tr{'yes'} <input type='image' alt='$Lang::tr{'yes'}' title='$Lang::tr{'yes'}' src='/images/edit-redo.png' />
227                                         <input type='hidden' name='ACTION' value='sharesresetyes' /></form></td>
228                         <td align='left'  width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
229                                         <input type='image' alt='$Lang::tr{'no'}' title='$Lang::tr{'no'}' src='/images/dialog-error.png' /> $Lang::tr{'no'} 
230                                         <input type='hidden' name='ACTION' value='cancel' /></form></td>
231         </tr>
232         </table>
233 END
234 ;
235         }
236
237 ############################################################################################################################
238 ########################################### Samba Benutzer oder PC l�chen #################################################
239
240 if ($sambasettings{'ACTION'} eq 'userdelete'){system("/usr/local/bin/sambactrl smbuserdelete $sambasettings{'NAME'}");refreshpage();}
241
242 ############################################################################################################################
243 ##################################### Umsetzen der Werte von Checkboxen und Dropdowns ######################################
244
245 if ($sambasettings{'ACTION'} eq $Lang::tr{'save'})
246 {
247 $sambasettings{'INTERFACES'} = '';
248 if ($sambasettings{'GREEN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'GREEN_DEV'}";}
249 if ($sambasettings{'BLUE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'BLUE_DEV'}";}
250 if ($sambasettings{'ORANGE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'ORANGE_DEV'}";}
251 if ($sambasettings{'VPN'} eq 'on'){$sambasettings{'INTERFACES'} .= " ";}
252 if ($sambasettings{'OTHERINTERFACES'} ne ''){ $sambasettings{'INTERFACES'} .= " $sambasettings{'OTHERINTERFACES'}";}
253
254 ############################################################################################################################
255 ##################################### Schreiben settings und bersetzen fr smb.conf #######################################
256
257 delete $sambasettings{'__CGI__'};delete $sambasettings{'x'};delete $sambasettings{'y'};
258 &General::writehash("${General::swroot}/samba/settings", \%sambasettings);
259
260 if ($sambasettings{'PASSWORDSYNC'} eq 'on'){ $sambasettings{'PASSWORDSYNC'} = "true";} else { $sambasettings{'PASSWORDSYNC'} = "false";}
261 if ($sambasettings{'WINSSUPPORT'} eq 'on'){ $sambasettings{'WINSSUPPORT'} = "true";$sambasettings{'WINSSRV'} = "";} else { $sambasettings{'WINSSUPPORT'} = "false";}
262 if ($sambasettings{'LOCALMASTER'} eq 'on'){ $sambasettings{'LOCALMASTER'} = "true";} else { $sambasettings{'LOCALMASTER'} = "false";}
263 if ($sambasettings{'DOMAINMASTER'} eq 'on'){ $sambasettings{'DOMAINMASTER'} = "true";} else { $sambasettings{'DOMAINMASTER'} = "false";}
264 if ($sambasettings{'PREFERREDMASTER'} eq 'on'){ $sambasettings{'PREFERREDMASTER'} = "true";} else { $sambasettings{'PREFERREDMASTER'} = "false";}
265 if ($sambasettings{'SYSLOGONLY'} eq 'on'){ $sambasettings{'SYSLOGONLY'} = "yes";} else { $sambasettings{'SYSLOGONLY'} = "no";}
266 if ($sambasettings{'WIDELINKS'} eq 'on'){ $sambasettings{'WIDELINKS'} = "yes";} else { $sambasettings{'WIDELINKS'} = "no";}
267 if ($sambasettings{'UNIXEXTENSION'} eq 'on'){ $sambasettings{'UNIXEXTENSION'} = "yes";} else { $sambasettings{'UNIXEXTENSION'} = "no";}
268
269 ############################################################################################################################
270 ############################################# Schreiben der Samba globals ##################################################
271
272         open (FILE, ">${General::swroot}/samba/global") or die "Can't save the global settings: $!";
273         flock (FILE, 2);
274         
275 print FILE <<END
276 # global.settings by IPFire Project
277
278 [global]
279 netbios name = $sambasettings{'NETBIOSNAME'}
280 server string = $sambasettings{'SRVSTRING'}
281 workgroup = $sambasettings{'WORKGRP'}
282 realm = $mainsettings{'DOMAINNAME'}
283 passdb backend = smbpasswd
284
285 wide links = $sambasettings{'WIDELINKS'}
286 unix extensions = $sambasettings{'UNIXEXTENSION'}
287 END
288 ;
289
290 if ($sambasettings{'SMB2'} eq 'on'){
291         print FILE "max protocol = smb2\n";
292 }
293
294 print FILE <<END
295 keep alive = 30
296 os level = $sambasettings{'OSLEVEL'}
297 fstype = NTFS
298
299 kernel oplocks = false
300 map to guest = $sambasettings{'MAPTOGUEST'}
301 smb ports = 445 139
302 dos charset = $sambasettings{'DOSCHARSET'}
303 unix charset = $sambasettings{'UNIXCHARSET'}
304 display charset = $sambasettings{'DISPLAYCHARSET'}
305
306 security = $sambasettings{'SECURITY'}
307 encrypt passwords = yes
308 guest account = $sambasettings{'GUESTACCOUNT'}
309 unix password sync = $sambasettings{'PASSWORDSYNC'}
310 null passwords = yes
311
312 bind interfaces only = true
313 interfaces = $sambasettings{'INTERFACES'}
314 socket options = $sambasettings{'SOCKETOPTIONS'}
315 remote announce = $sambasettings{'REMOTEANNOUNCE'}
316 remote browse sync = $sambasettings{'REMOTESYNC'}
317
318 username level = 1
319 wins support = $sambasettings{'WINSSUPPORT'}
320 wins server = $sambasettings{'WINSSRV'}
321
322 winbind separator = +
323 winbind uid = 10000-20000
324 winbind gid = 10000-20000
325 winbind use default domain = yes
326
327 log file       = /var/log/samba/samba-log.%m
328 lock directory = /var/lock/samba
329 pid directory  = /var/run/
330 log level = $sambasettings{'LOGLEVEL'}
331 syslog = $sambasettings{'SYSLOGLEVEL'}
332 syslog only = $sambasettings{'SYSLOGONLY'}
333
334 preferred master = $sambasettings{'PREFERREDMASTER'}
335 domain master = $sambasettings{'DOMAINMASTER'}
336 local master = $sambasettings{'LOCALMASTER'}
337
338 END
339 ;
340 close FILE;
341
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
346 load printers = $sambasettings{'LOADPRINTERS'}
347 printing = $sambasettings{'PRINTING'}
348 printcap name = $sambasettings{'PRINTCAPNAME'}
349
350 END
351 ;
352 close FILE;
353         }
354
355         if ($sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' )
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
366 $sambasettings{'PDCOPTIONS'}
367 END
368 ;
369         close FILE;
370         }
371
372 if ( -e "/var/ipfire/cups/enable")
373         {
374         if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdccups");refreshpage();}
375         else {system("/usr/local/bin/sambactrl smbsafeconfcups");}
376         }
377 else
378         {
379         if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdc");refreshpage();}
380         else{system("/usr/local/bin/sambactrl smbsafeconf");}
381         }
382
383 system("/usr/local/bin/sambactrl smbreload");refreshpage();
384 }
385   &General::readhash("${General::swroot}/samba/settings", \%sambasettings);
386   
387
388 if ($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         }
395
396 if ($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
405 ############################################################################################################################
406 ########################################## Aktivieren von Checkboxen und Dropdowns #########################################
407
408 $checked{'SYSLOGONLY'}{'off'} = '';
409 $checked{'SYSLOGONLY'}{'on'} = '';
410 $checked{'SYSLOGONLY'}{$sambasettings{'SYSLOGONLY'}} = "checked='checked'";
411 $checked{'WINSSUPPORT'}{'off'} = '';
412 $checked{'WINSSUPPORT'}{'on'} = '';
413 $checked{'WINSSUPPORT'}{$sambasettings{'WINSSUPPORT'}} = "checked='checked'";
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'";
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'";
432 $checked{'SMB2'}{'off'} = '';
433 $checked{'SMB2'}{'on'} = '';
434 $checked{'SMB2'}{$sambasettings{'SMB2'}} = "checked='checked'";
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'";
447
448 if ( $sambasettings{'MAPTOGUEST'} eq "Never" ) {
449         $sambasettings{'MAPTOGUEST'}="Bad User";
450 }
451 $selected{'MAPTOGUEST'}{$sambasettings{'MAPTOGUEST'}} = "selected='selected'";
452 $selected{'SECURITY'}{$sambasettings{'SECURITY'}} = "selected='selected'";
453
454 ############################################################################################################################
455 ################################### Aufbau der HTML Seite fr globale Sambaeinstellungen ###################################
456
457 &Header::openbox('100%', 'center', $Lang::tr{'samba'});
458 print <<END
459 <br />
460 <table width='95%' cellspacing='0'>
461 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'all services'}</b></td></tr>
462 </table><table width='95%' cellspacing='0'>
463 END
464 ;
465
466 my $key = '';
467 foreach $key (sort keys %servicenames)
468         {
469         print "<tr><td align='left' width='40%'>$key</td>";
470         my $shortname = $servicenames{$key};
471         my $status = &isrunning($shortname);
472         print "$status</tr>";
473         }
474
475 print <<END
476 </table>
477 <br />
478 <table width='95%' cellspacing='0'>
479 <tr><td align='left' width='40%' />
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>
483 </table>
484 <br />
485 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
486 <table width='95%' cellspacing='0'>
487 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'basic options'}</b></td></tr>
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>
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>
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>
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'} />/
497                                                                                                                                                                                         <input type='radio' name='SYSLOGONLY' value='off' $checked{'SYSLOGONLY'}{'off'} /> off</td></tr>
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'} />/
499                                                                                                                                                                                 <input type='radio' name='VPN' value='off' $checked{'VPN'}{'off'} /> off |
500                                                                                                                                                                                 <font size='2' color='$Header::colourovpn'><b>   OpenVpn  -  $ovpnip[0].$ovpnip[1].$ovpnip[2].$ovpnip[3]/$ovpnnetwork[1]</b></font></td></tr>
501 <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='GREEN' value='on' $checked{'GREEN'}{'on'} />/
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>
504 END
505 ;
506
507 if (&Header::blue_used())
508         {
509         print <<END
510         <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='BLUE' value='on' $checked{'BLUE'}{'on'} />/
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>
513 END
514 ;
515         }
516
517 if (&Header::orange_used())
518         {
519         print <<END
520         <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='ORANGE' value='on' $checked{'ORANGE'}{'on'} />/
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>
523 END
524 ;
525         }
526
527 print <<END
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>
529 <tr><td align='left'><br /></td><td></td></tr>
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>
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>
536 <tr><td align='left'><br /></td><td></td></tr>
537 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'security options'}</b></td></tr>
538 <tr><td align='left' width='40%'>$Lang::tr{'security'}</td><td align='left'><select name='SECURITY' style="width: 165px">
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>
545 <tr><td align='left' width='40%'>$Lang::tr{'map to guest'}</td><td align='left'><select name='MAPTOGUEST' style="width: 165px">
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>
549 END
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>
553 print <<END
554 <tr><td align='left'><br /></td><td /></tr>
555 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'network options'}</b></td></tr>
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>
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>
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>
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>
560 END
561 ;
562 if ($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>";}
563         print <<END
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'} />/
565                                                                                                                                                                                                 <input type='radio' name='WINSSUPPORT' value='off' $checked{'WINSSUPPORT'}{'off'} /> off</td></tr>
566 END
567 ;
568
569 if ($sambasettings{'SECURITY'} eq 'user')
570         {
571         print <<END
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'} />/
573                                                                                                                                                                                         <input type='radio' name='LOCALMASTER' value='off' $checked{'LOCALMASTER'}{'off'} /> off</td></tr>
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'} />/
575                                                                                                                                                                                                 <input type='radio' name='DOMAINMASTER' value='off' $checked{'DOMAINMASTER'}{'off'} /> off</td></tr>
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'} />/
577                                                                                                                                                                                                         <input type='radio' name='PREFERREDMASTER' value='off' $checked{'PREFERREDMASTER'}{'off'} /> off</td></tr>
578 END
579 ;
580         }
581
582 if ($sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'on')
583         {
584         print <<END
585         <tr><td align='left'><br /></td><td></td></tr>
586         <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'pdc options'}</b></td></tr>
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>
589 END
590 ;
591         }
592         
593         if ( -e "/var/ipfire/cups/enable")
594         {
595         print <<END
596         <tr><td align='left'><br /></td><td></td></tr>
597         <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'printing options'}</b></td></tr>
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>
601 END
602 ;
603         }
604
605 print <<END
606 </table>
607 <br />
608 <table width='10%' cellspacing='0'>
609 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
610                                                                                                 <input type='hidden' name='ACTION' value=$Lang::tr{'save'} />
611                                                                                                 <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></form></td>
612 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
613                                                                                 <input type='hidden' name='ACTION' value='globalreset' />
614                                                                                 <input type='image' alt='$Lang::tr{'reset'}' title='$Lang::tr{'reset'}' src='/images/reload.gif' /></form></td>
615 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
616                                                                                 <input type='hidden' name='ACTION' value='globalcaption' />
617                                                                                 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form></td></tr>
618 </table>
619 END
620 ;
621
622 if ($sambasettings{'ACTION'} eq 'globalcaption')
623         {
624         print <<END
625         <br />
626         <table width='95%' cellspacing='0'>
627         <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
628         <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save settings'}</td></tr>
629         <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'restore settings'}</td></tr>
630         </table>
631 END
632 ;
633         }
634
635 &Header::closebox();
636
637 ############################################################################################################################
638 ########################################## Benutzerverwaltung fr Usersecurity #############################################
639
640 if ($sambasettings{'SECURITY'} eq 'user')
641         {
642         if ($sambasettings{'DOMAINMASTER'} eq 'off')
643                 {
644                 &Header::openbox('100%', 'center', $Lang::tr{'accounting user nonpdc'});
645                 }
646         else
647                 {
648                 &Header::openbox('100%', 'center', $Lang::tr{'accounting user pdc'});
649                 }
650         print <<END
651         <a name="$Lang::tr{'accounting'}"></a>
652         <br />
653         <table width='95%' cellspacing='0'>
654         <tr><td colspan='6' align='left'></td></tr>
655         <tr><td bgcolor='$color{'color20'}' colspan='7' align='left'><b>$Lang::tr{'accounting'}</b></td></tr>
656         <tr><td align='left'><u>$Lang::tr{'username'}</u></td><td align='left'><u>$Lang::tr{'password'}</u></td>
657 END
658 ;
659
660         if ($sambasettings{'DOMAINMASTER'} eq 'off')
661                 {
662                 print "<td></td>";
663                 }
664         else
665                 {
666                 print "<td align='left'><u>$Lang::tr{'type'}</u></td>";
667                 }
668
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>";
670         system('/usr/local/bin/sambactrl readsmbpasswd');
671         open(FILE, "<${General::swroot}/samba/private/smbpasswd") or die "Can't read user file: $!";
672         @user = <FILE>;
673         close(FILE);
674         system('/usr/local/bin/sambactrl locksmbpasswd');
675         
676         my $lines = 0;
677         
678         foreach $userentry (sort @user)
679                 {
680                 @userline = split( /\:/, $userentry );
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'>";
683                 if ($userline[4] =~ /N/)
684                         {
685                         print "$Lang::tr{'not set'}</td><td align='left'>";
686                         }
687                 else
688                         {
689                         print "$Lang::tr{'set'}</td><td align='left'>";
690                         }
691
692                 if ($sambasettings{'DOMAINMASTER'} eq 'off')
693                         {
694                         print "</td><td align='left'>";
695                         }
696                 else
697                         {
698                         if ($userline[0] =~ /\$/)
699                                 {
700                                 print "$Lang::tr{'pc'}</td><td align='left'>";
701                                 }
702                         else
703                                 {
704                                 print "$Lang::tr{'user'}</td><td align='left'>";
705                                 }
706                         }
707
708                 if ($userline[4] =~ /D/)
709                         {
710                         print <<END
711                         $Lang::tr{'inactive'}</td>
712                         <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
713                                         <input type='hidden' name='NAME' value='$userline[0]' />
714                                         <input type='hidden' name='ACTION' value='smbuserenable' />
715                                         <input type='image' alt='$Lang::tr{'activate'}' title='$Lang::tr{'activate'}' src='/images/off.gif' />
716                         </form></td>
717 END
718 ;
719                         }
720                 else
721                         {
722                         print <<END
723                         $Lang::tr{'active'}</td>
724                         <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
725                                         <input type='hidden' name='NAME' value='$userline[0]' />
726                                         <input type='hidden' name='ACTION' value='smbuserdisable' />
727                                         <input type='image' alt='$Lang::tr{'deactivate'}' title='$Lang::tr{'deactivate'}' src='/images/on.gif' />
728                         </form></td>
729 END
730 ;
731                         }
732
733                 if ($userline[0] =~ /\$/)
734                         {
735                         print "<td></td>";
736                         }
737                 else
738                         {
739                         print <<END
740                         <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
741                                         <input type='hidden' name='NAME' value='$userline[0]' />
742                                         <input type='hidden' name='ACTION' value='userchangepw' />
743                                         <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
744                         </form></td>
745 END
746 ;
747                         }
748
749                         if ($sambasettings{'DOMAINMASTER'} eq 'on' && $userline[0] =~ /\$/)
750                                 {
751                                 print <<END
752                                 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
753                                                 <input type='hidden' name='NAME' value='$userline[0]' />
754                                                 <input type='hidden' name='ACTION' value='userdelete' />
755                                                 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/network-error.png' />
756                                                 </form></td></tr>
757 END
758 ;
759                                 }
760                         else
761                                 {
762                                 print <<END
763                                 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
764                                                 <input type='hidden' name='NAME' value='$userline[0]' />
765                                                 <input type='hidden' name='ACTION' value='userdelete' />
766                                                 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-option-remove.png' />
767                                 </form></td></tr>
768 END
769 ;
770                                 }
771                 $lines++;
772                 }
773         print <<END
774         </table>
775         <br />
776         <table width='10%' cellspacing='0'>
777         <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
778                                                                                                         <input type='hidden' name='ACTION' value='useradd' />
779                                                                                                         <input type='image' alt='$Lang::tr{'add user'}' title='$Lang::tr{'add user'}' src='/images/user-option-add.png' /></form></td>
780 END
781 ;
782
783         if ($sambasettings{'DOMAINMASTER'} eq 'on')
784                 {
785                 print <<END
786                 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
787                                                                                                 <input type='hidden' name='ACTION' value='pcadd' />
788                                                                                                 <input type='image' alt='$Lang::tr{'pc add'}' title='$Lang::tr{'pc add'}' src='/images/network.png' /></form>
789 END
790 ;
791                 }
792         print <<END
793         <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
794                                                                                         <input type='hidden' name='ACTION' value='usercaption' />
795                                                                                         <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form>
796         </td></tr>
797         </table>
798 END
799 ;
800
801         if ($sambasettings{'ACTION'} eq 'usercaption')
802                 {
803                 print <<END
804                 <br />
805                 <table width='95%' cellspacing='0'>
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>
808                 <tr><td align='right' width='33%'><img src='/images/network.png' /></td><td align='left'>$Lang::tr{'pc add'}</td></tr>
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>
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>
813                 <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'change passwords'}</td></tr>
814                 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr>
815                 </table>
816 END
817 ;
818                 }
819
820         if ($sambasettings{'ACTION'} eq 'userchangepw')
821                 {
822                 my $username = "$sambasettings{'NAME'}";
823                 my $password = 'samba';
824                 print <<END
825                 <br />
826                 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
827                 <table width='95%' cellspacing='0'>
828                 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'change passwords'}</b></td></tr>
829                 <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' readonly='readonly' /></td></tr>
830                 <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr>
831                 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbchangepw' />
832                         <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></td></tr>
833                 </table>
834                 </form>
835 END
836 ;
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
848                 <br />
849                 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
850                 <table width='95%' cellspacing='0'>
851                 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add user'}</b></td></tr>
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>
856                 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbuseradd' />
857                         <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></td></tr>
858                 </table>
859                 </form>
860 END
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
870                 <br />
871                 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
872                 <table width='95%' cellspacing='0'>
873                 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'pc add'}</b></td></tr>
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>
877                 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbpcadd' />
878                         <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></td></tr>
879                 </table>
880                 </form>
881 END
882 ;
883                 }
884
885 &Header::closebox();
886 }
887
888 if ($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>
932 END
933
934         &Header::closebox();
935 }
936
937 ############################################################################################################################
938 ############################################### Verwalten von Freigaben ####################################################
939
940 &Header::openbox('100%', 'center', $Lang::tr{'shares'});
941
942 my %shares =  config("${General::swroot}/samba/shares");
943
944
945 print <<END
946 <a name="$Lang::tr{'manage shares'}"></a>
947 <br />
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>
951 END
952 ;
953
954 my @Shares = keys(%shares);
955 my $lines = 0;
956 my $col="";
957 foreach my $shareentry (sort @Shares)
958         {
959         chomp $shareentry;
960         if ($lines % 2) {
961                 print "<tr>";
962                 $col="bgcolor='$color{'color20'}'";
963         } else {
964                 print "<tr>";
965                 $col="bgcolor='$color{'color22'}'";
966         }
967         print <<END
968         <td align='left' $col>$shareentry</td>
969         <td $col><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
970                         <input type='hidden' name='NAME' value='$shareentry' />
971                         <input type='hidden' name='ACTION' value='sharechange' />
972                         <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
973         </form></td>
974         <td $col><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
975                         <input type='hidden' name='NAME' value='$shareentry' />
976                         <input type='hidden' name='ACTION' value='smbsharedel' />
977                         <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' />
978         </form></td></tr>
979 END
980 ;
981   $lines++;
982         }
983
984 print <<END
985 </table>
986 <br />
987 <table width='10%' cellspacing='0'>
988 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
989                                                                                                 <input type='hidden' name='ACTION' value='shareadd' />
990                                                                                                 <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/list-add.png' />
991                                                                                                 </form></td>
992                 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
993                                                                                                 <input type='hidden' name='ACTION' value='sharesreset' />
994                                                                                                 <input type='image' alt='$Lang::tr{'reset'}' title='$Lang::tr{'reset'}' src='/images/reload.gif' />
995                                                                                                 </form></td>
996                 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
997                                                                                                 <input type='hidden' name='ACTION' value='sharecaption' />
998                                                                                                 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' />
999                                                                                                 </form></td>
1000 </tr>
1001 </table>
1002 END
1003 ;
1004
1005 if ($sambasettings{'ACTION'} eq 'sharecaption')
1006         {
1007         print <<END
1008         <br />
1009         <table width='95%' cellspacing='0'>
1010         <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
1011         <tr><td align='right' width='33%'><img src='/images/list-add.png' /></td><td align='left'>$Lang::tr{'add share'}</td></tr>
1012         <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'edit share'}</td></tr>
1013         <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr>
1014         <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'reset shares'}</td></tr>
1015         <tr><td align='right' width='33%'><img src='/images/user-trash.png' /></td><td align='left'>$Lang::tr{'delete share'}</td></tr>
1016         </table>
1017 END
1018 ;
1019         }
1020
1021 if ($sambasettings{'ACTION'} eq 'shareadd' || $sambasettings{'ACTION'} eq 'optioncaption' )
1022         {
1023         print <<END
1024         <br />
1025         <table width='95%' cellspacing='0'>
1026         <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add share'}</b></td></tr>
1027         <tr><td colspan='2' align='center'></td></tr>
1028         <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}
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>
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>
1031         </table>
1032         <br />
1033         <table width='10%' cellspacing='0'>
1034         <tr><td align='center'><input type='hidden' name='ACTION' value='smbshareadd' />
1035                                                                                                         <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/media-floppy.png' /></td></tr></form>
1036         </table>
1037 END
1038 ;
1039         }
1040
1041 if ($sambasettings{'ACTION'} eq 'sharechange' || $sambasettings{'ACTION'} eq 'optioncaption2' )
1042         {
1043         my $shareoption = $shares{$sambasettings{'NAME'}};
1044         print <<END
1045         <br />
1046         <table width='95%' cellspacing='0'>
1047         <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'edit share'}</b></td></tr>
1048         <tr><td colspan='2' align='center'></td></tr>
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>
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>
1051         </table>
1052         <br />
1053         <table width='10%' cellspacing='0'>
1054         <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' />
1055                                                                                                         <input type='image' alt='$Lang::tr{'change share'}' title='$Lang::tr{'change share'}' src='/images/media-floppy.png' />
1056                                                                                                         <input type='hidden' name='ACTION' value='smbsharechange' /></form></td></tr>
1057         </table>
1058 END
1059 ;
1060         }
1061
1062 if ($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         }
1068 if ($sambasettings{'ACTION'} eq 'smbshareadd')
1069         {
1070         $shares{'xvx'}= "$sambasettings{'SHAREOPTION'}";
1071         save("shares");
1072         my $shares = config("${General::swroot}/samba/shares");
1073         }
1074 if ($sambasettings{'ACTION'} eq 'smbsharedel')
1075         {
1076         delete $shares{$sambasettings{'NAME'}};
1077         save("shares");
1078         my %shares = config("${General::swroot}/samba/shares");
1079         }
1080 if ($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
1092 my %printer =  config("${General::swroot}/samba/printer");
1093
1094 if ( -e "/var/ipfire/cups/enable")
1095 {
1096 &Header::openbox('100%', 'center', $Lang::tr{'printer'});
1097
1098 my @Printers = keys(%printer);
1099 print <<END
1100 <a name="$Lang::tr{'manage printers'}"></a>
1101 <br />
1102 <table width='95%' cellspacing='0'>
1103 <tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'manage printers'}</b>
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>
1105 END
1106 ;
1107 foreach my $printerentry (sort @Printers)
1108         {
1109         chomp $printerentry;
1110         print <<END
1111         <tr><td align='left'>$printerentry</td>
1112         <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
1113                         <input type='hidden' name='NAME' value='$printerentry' />
1114                         <input type='hidden' name='ACTION' value='printerchange' />
1115                         <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
1116         </form></td>
1117         <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
1118                         <input type='hidden' name='NAME' value='$printerentry' />
1119                         <input type='hidden' name='ACTION' value='smbprinterdel' />
1120                         <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' />
1121         </form></td></tr>
1122 END
1123 ;
1124         }
1125 print <<END
1126 </table>
1127 <br />
1128 <table width='10%' cellspacing='0'>
1129 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
1130                                                                                                 <input type='hidden' name='ACTION' value='printeradd' />
1131                                                                                                 <input type='image' alt='$Lang::tr{'add printer'}' title='$Lang::tr{'add printer'}' src='/images/list-add.png' />
1132                                                                                                 </form></td>
1133                 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
1134                                                                                                 <input type='hidden' name='ACTION' value='printereset' />
1135                                                                                                 <input type='image' alt='$Lang::tr{'reset'}' title='$Lang::tr{'reset'}' src='/images/reload.gif' />
1136                                                                                                 </form></td>
1137                 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
1138                                                                                                 <input type='hidden' name='ACTION' value='printercaption' />
1139                                                                                                 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' />
1140                                                                                                 </form></td>
1141 </tr>
1142 </table>
1143 END
1144 ;
1145
1146 if ($sambasettings{'ACTION'} eq 'printeradd' || $sambasettings{'ACTION'} eq 'printercaption' )
1147         {
1148         print <<END
1149         <br />
1150         <table width='95%' cellspacing='0'>
1151         <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add printer'}</b></td></tr>
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>
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>
1156         </table>
1157         <br />
1158         <table width='10%' cellspacing='0'>
1159         <tr><td align='center'><input type='hidden' name='ACTION' value='smbprinteradd' />
1160                                                                                                         <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/media-floppy.png' /></td></tr>
1161         </table>
1162         </form>
1163 END
1164 ;
1165         }
1166         
1167 if ($sambasettings{'ACTION'} eq 'printerchange' || $sambasettings{'ACTION'} eq 'printercaption2' )
1168         {
1169         my $printeroption = $printer{$sambasettings{'NAME'}};
1170         print <<END
1171         <br />
1172         <table width='95%' cellspacing='0'>
1173         <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'edit printer'}</b></td></tr>
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>
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>
1177         </table>
1178         <br />
1179         <table width='10%' cellspacing='0'>
1180         <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' />
1181                                                                                                         <input type='image' alt='$Lang::tr{'change share'}' title='$Lang::tr{'change share'}' src='/images/media-floppy.png' />
1182                                                                                                         <input type='hidden' name='ACTION' value='smbprinterchange' /></form></td></tr>
1183         </table>
1184 END
1185 ;
1186         }
1187
1188 if ($sambasettings{'ACTION'} eq 'smbprinteradd')
1189         {
1190         $printer{'xvx'}= "$sambasettings{'PRINTEROPTION'}";
1191         save("printer");
1192         my %printer = config("${General::swroot}/samba/printer");
1193         }
1194
1195 if ($sambasettings{'ACTION'} eq 'smbprinterdel')
1196         {
1197         delete $printer{$sambasettings{'NAME'}};
1198         save("printer");
1199         my %printer = config("${General::swroot}/samba/printer");
1200         }
1201
1202 if ($sambasettings{'ACTION'} eq 'smbprinterchange')
1203         {
1204         $printer{$sambasettings{'NAME'}} = $sambasettings{'PRINTEROPTION'};
1205         save("printer");
1206         my %printer = config("${General::swroot}/samba/printer");
1207         }
1208
1209 &Header::closebox();
1210 }
1211
1212 ############################################################################################################################
1213 ############################################### Anzeige des Sambastatus ####################################################
1214
1215 &Header::openbox('100%', 'center', 'Status');
1216
1217 print <<END
1218 <br />
1219 <table width='95%' cellspacing='0'>
1220 <tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'samba status'}</b></td></tr>
1221 <tr><td  align='left'>$Status</td></tr>
1222 </table>
1223 END
1224 ;
1225 &Header::closebox();
1226
1227 ############################################################################################################################
1228 ############################################### Anzeige der Sambalogs ######################################################
1229
1230
1231 if ($sambasettings{'ACTION'} eq 'showlog')
1232 {
1233 $Log = qx(tail -n $sambasettings{'LOGLINES'} /var/log/samba/$sambasettings{'LOG'});
1234 $Log=~s/\n/<br \/>/g;
1235 }
1236
1237 &Header::openbox('100%', 'center', $Lang::tr{'log'});
1238
1239 print <<END
1240 <a name="$Lang::tr{'log view'}"></a>
1241 <br />
1242 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'log view'}'>
1243 <table width='95%' cellspacing='0'>
1244 <tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'log view'}</b></td></tr>
1245 <tr><td colspan='3'  align='left'><br /></td></tr>
1246 <tr><td  align='left'><select name='LOG' style="width: 200px">
1247 END
1248 ;
1249 foreach my $log (@Logs) {chomp $log;print"<option value='$log'>$log</option>";}
1250 print <<END
1251
1252 </select></td><td  align='left'>$Lang::tr{'show last x lines'}<input type='text' name='LOGLINES' value='$LOGLINES' size="3" /></td>
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>
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>
1258 </table>
1259 </form>
1260 END
1261 ;
1262 &Header::closebox();
1263 &Header::closebigbox();
1264 &Header::closepage();
1265
1266 ############################################################################################################################
1267 ############################################ Subfunktion fr Sambadienste ###################################################
1268
1269 sub config
1270 {
1271 my $file = shift;
1272 my @allarray = `grep -n '^\\[' $file`;
1273 my @linesarray = ();
1274 my @namearray = ();
1275 my %hash = ();
1276 my $options = ();
1277 my $EOF = qx(cat $file | wc -l);
1278 foreach 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";
1299                 #print"<pre>$namearray[$i]\n$options\n</pre>"; # enable only for debuging
1300                 }
1301 return(%hash);
1302 }
1303
1304 sub save
1305 {
1306 my $smb = shift;
1307 open (FILE, ">${General::swroot}/samba/$smb") or die "Can't $smb settings $!";
1308 flock (FILE, 2);
1309
1310 if ( $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
1313 if ( $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
1316 close FILE;
1317
1318 if ( -e "/var/ipfire/cups/enable")
1319         {
1320         if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdccups");}
1321         else {system("/usr/local/bin/sambactrl smbsafeconfcups");}
1322         }
1323 else
1324         {
1325         if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdc");}
1326         else{system("/usr/local/bin/sambactrl smbsafeconf");}
1327         }
1328
1329 system("/usr/local/bin/sambactrl smbreload");
1330 refreshpage();
1331 }
1332
1333 sub isrunning
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;
1365         }
1366
1367 sub 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 }