]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/changepw.cgi
Firewallhitgraphs gefixt.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / changepw.cgi
CommitLineData
ac1cfefa
MT
1#!/usr/bin/perl
2#
3# SmoothWall CGIs
4#
5# This code is distributed under the terms of the GPL
6#
7# (c) The SmoothWall Team
8#
9# $Id: changepw.cgi,v 1.4.2.6 2005/03/07 21:28:03 eoberlander Exp $
10#
11
12use strict;
13
14# enable only the following on debugging purpose
15#use warnings;
16#use CGI::Carp 'fatalsToBrowser';
17
986e08d9 18require '/var/ipfire/general-functions.pl';
ac1cfefa
MT
19require "${General::swroot}/lang.pl";
20require "${General::swroot}/header.pl";
21
22my %cgiparams=();
23my $errormessage='';
24
25&Header::showhttpheaders();
26
27$cgiparams{'ACTION_ADMIN'} = '';
28$cgiparams{'ACTION_DIAL'} = '';
29
30&Header::getcgihash(\%cgiparams);
31
32if ($cgiparams{'ACTION_ADMIN'} eq $Lang::tr{'save'})
33{
34 my $password1 = $cgiparams{'ADMIN_PASSWORD1'};
35 my $password2 = $cgiparams{'ADMIN_PASSWORD2'};
36 if ($password1 eq $password2)
37 {
38 if ($password1 =~ m/\s|\"/) {
39 $errormessage = $Lang::tr{'password contains illegal characters'};
40 }
41 elsif (length($password1) >= 6)
42 {
647ba968 43 system('/usr/sbin/htpasswd', '-m', '-b', "${General::swroot}/auth/users", 'admin', "${password1}");
ac1cfefa
MT
44 &General::log($Lang::tr{'admin user password has been changed'});
45 }
46 else {
47 $errormessage = $Lang::tr{'passwords must be at least 6 characters in length'}; }
48 }
49 else {
50 $errormessage = $Lang::tr{'passwords do not match'}; }
51}
52
53if ($cgiparams{'ACTION_DIAL'} eq $Lang::tr{'save'})
54{
55 my $password1 = $cgiparams{'DIAL_PASSWORD1'};
56 my $password2 = $cgiparams{'DIAL_PASSWORD2'};
57 if ($password1 eq $password2)
58 {
59 if($password1 =~ m/\s|\"/) {
60 $errormessage = $Lang::tr{'password contains illegal characters'};
61 }
62 elsif (length($password1) >= 6)
63 {
647ba968 64 system('/usr/sbin/htpasswd', '-m', '-b', "${General::swroot}/auth/users", 'dial', "${password1}");
ac1cfefa
MT
65 &General::log($Lang::tr{'dial user password has been changed'});
66 }
67 else {
68 $errormessage = $Lang::tr{'passwords must be at least 6 characters in length'}; }
69 }
70 else {
71 $errormessage = $Lang::tr{'passwords do not match'}; }
72}
73
74&Header::openpage($Lang::tr{'change passwords'}, 1, '');
75
76&Header::openbigbox('100%', 'left', '', $errormessage);
77
78if ($errormessage) {
79 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
80 print "<class name='base'>$errormessage\n";
81 print "&nbsp;</class>\n";
82 &Header::closebox();
83}
84
85print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
86
87&Header::openbox('100%', 'left', $Lang::tr{'administrator user password'});
88print <<END
89<table width='100%'>
90<tr>
91 <td width='20%' class='base'>$Lang::tr{'username'}&nbsp;'admin'</td>
92 <td width='15%' class='base' align='right'>$Lang::tr{'password'}&nbsp;</td>
93 <td width='15%'><input type='password' name='ADMIN_PASSWORD1' size='10' /></td>
94 <td width='15%' class='base' align='right'>$Lang::tr{'again'} </td>
95 <td width='15%'><input type='password' name='ADMIN_PASSWORD2' size='10' /></td>
96 <td width='20%' align='center'><input type='submit' name='ACTION_ADMIN' value='$Lang::tr{'save'}' /></td>
97</tr>
98</table>
99END
100;
101&Header::closebox();
102
103&Header::openbox('100%', 'left', $Lang::tr{'dial user password'});
104print <<END
105<table width='100%'>
106<tr>
107 <td width='20%' class='base'>$Lang::tr{'username'}&nbsp;'dial'</td>
108 <td width='15%' class='base' align='right'>$Lang::tr{'password'}&nbsp;</td>
109 <td width='15%'><input type='password' name='DIAL_PASSWORD1' size='10'/></td>
110 <td width='15%' class='base' align='right'>$Lang::tr{'again'}&nbsp;</td>
111 <td width='15%'><input type='password' name='DIAL_PASSWORD2' size='10' /></td>
112 <td width='20%' align='center'><input type='submit' name='ACTION_DIAL' value='$Lang::tr{'save'}' /></td>
113</tr>
114</table>
115END
116;
117&Header::closebox();
118
119print "</form>\n";
120
121&Header::closebigbox();
122
123&Header::closepage();