From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: development@lists.ipfire.org Subject: Re: [PATCH] Added language support for chpasswd.cgi Date: Wed, 04 Oct 2017 16:51:06 +0100 Message-ID: <1507132266.433.15.camel@ipfire.org> In-Reply-To: <1507122180-16347-1-git-send-email-erik.kapfer@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============9163073170971008103==" List-Id: --===============9163073170971008103== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, good patch. On Wed, 2017-10-04 at 15:03 +0200, Erik Kapfer wrote: > --- > html/cgi-bin/chpasswd.cgi | 57 +++++++++++++++++++++++++++----------------= --- > - > 1 file changed, 33 insertions(+), 24 deletions(-) >=20 > diff --git a/html/cgi-bin/chpasswd.cgi b/html/cgi-bin/chpasswd.cgi > index 0a66062..00494f2 100644 > --- a/html/cgi-bin/chpasswd.cgi > +++ b/html/cgi-bin/chpasswd.cgi > @@ -19,15 +19,26 @@ > # = =20 > # > ##########################################################################= ### > ## > =20 > +use strict; > + > +#usable only the following on debugging purpose > +#use warnings; > +#use CGI::Carp 'fatalsToBrowser'; > + > use CGI qw(param); > use Apache::Htpasswd; > use Crypt::PasswdMD5; > =20 > -$swroot =3D "/var/ipfire"; > - > my %cgiparams; > my %mainsettings; > my %proxysettings; > +my %netsettings; > +my %temp; > +my $swroot; > +my $errormessage; > +my $language; > + > +$swroot =3D "/var/ipfire"; You could have dropped the $swroot variable and use $General::swroot like you did with many other variables. Would you send an updated patch? -Michael > =20 > $proxysettings{'NCSA_MIN_PASS_LEN'} =3D 6; > =20 > @@ -38,12 +49,10 @@ $language =3D $mainsettings{'LANGUAGE'}; > =20 > ### Initialize language > if ($language =3D~ /^(\w+)$/) {$language =3D $1;} > - # > - # Uncomment this to force a certain language: > - # $language=3D'en'; > - # > -require "${swroot}/langs/en.pl"; > -require "${swroot}/langs/${language}.pl"; > + > +require '/var/ipfire/general-functions.pl'; > +require "${General::swroot}/lang.pl"; > +require "${General::swroot}/header.pl"; > =20 > my $userdb =3D "$swroot/proxy/advanced/ncsa/passwd"; > =20 > @@ -53,26 +62,26 @@ my $success =3D 0; > =20 > &getcgihash(\%cgiparams); > =20 > -if ($cgiparams{'SUBMIT'} eq $tr{'advproxy chgwebpwd change password'}) > +if ($cgiparams{'SUBMIT'} eq $Lang::tr{'advproxy chgwebpwd change password'= }) > { > if ($cgiparams{'USERNAME'} eq '') > { > - $errormessage =3D $tr{'advproxy errmsg no username'}; > + $errormessage =3D $Lang::tr{'advproxy errmsg no username'}; > goto ERROR; > } > if (($cgiparams{'OLD_PASSWORD'} eq '') || > ($cgiparams{'NEW_PASSWORD_1'} eq '') || ($cgiparams{'NEW_PASSWORD_2'} eq ''= )) > { > - $errormessage =3D $tr{'advproxy errmsg no password'}; > + $errormessage =3D $Lang::tr{'advproxy errmsg no password'}; > goto ERROR; > } > if (!($cgiparams{'NEW_PASSWORD_1'} eq $cgiparams{'NEW_PASSWORD_2'})) > { > - $errormessage =3D $tr{'advproxy errmsg passwords different'}; > + $errormessage =3D $Lang::tr{'advproxy errmsg passwords > different'}; > goto ERROR; > } > if (length($cgiparams{'NEW_PASSWORD_1'}) < > $proxysettings{'NCSA_MIN_PASS_LEN'}) > { > - $errormessage =3D $tr{'advproxy errmsg password length > 1'}.$proxysettings{'NCSA_MIN_PASS_LEN'}.$tr{'advproxy errmsg password length > 2'}; > + $errormessage =3D $Lang::tr{'advproxy errmsg password length > 1'}.$proxysettings{'NCSA_MIN_PASS_LEN'}.$Lang::tr{'advproxy errmsg password > length 2'}; > goto ERROR; > } > =20 > @@ -81,14 +90,14 @@ if ($cgiparams{'SUBMIT'} eq $tr{'advproxy chgwebpwd cha= nge > password'}) > # Check if a user with this name exists > my $old_password =3D $htpasswd->fetchPass($cgiparams{'USERNAME'}); > if (!$old_password) { > - $errormessage =3D $tr{'advproxy errmsg invalid user'}; > + $errormessage =3D $Lang::tr{'advproxy errmsg invalid user'}; > goto ERROR; > } > =20 > # Reset password > if (!$htpasswd->htpasswd($cgiparams{'USERNAME'}, > $cgiparams{'NEW_PASSWORD_1'}, > $cgiparams{'OLD_PASSWORD'})) { > - $errormessage =3D $tr{'advproxy errmsg password incorrect'}; > + $errormessage =3D $Lang::tr{'advproxy errmsg password > incorrect'}; > goto ERROR; > } > =20 > @@ -103,7 +112,7 @@ print "Cache-control: no-cache\n"; > print "Connection: close\n"; > print "Content-type: text/html\n\n"; > =20 > -print < +print < > > > @@ -124,7 +133,7 @@ print < > > color=3D"#FFFFFF" size=3D"4"> > - $tr{'advproxy chgwebpwd change web password'} > + $Lang::tr{'advproxy chgwebpwd change web > password'} > > > > @@ -134,7 +143,7 @@ print < > align=3D"left"> > sans-serif" color=3D"#666666" size=3D"2"> > - $tr{'advproxy chgwebpwd > username'}: > + $Lang::tr{'advproxy chgwebpwd > username'}: > > > name=3D"USERNAME" value=3D"$cgiparams{'USERNAME'}" size=3D"30"> > @@ -142,7 +151,7 @@ print < > align=3D"left"> > sans-serif" color=3D"#666666" size=3D"2"> > - $tr{'advproxy chgwebpwd old > password'}: > + $Lang::tr{'advproxy chgwebpwd old > password'}: > > > name=3D"OLD_PASSWORD" value=3D"$cgiparams{'OLD_PASSWORD'}" size=3D"30"> > @@ -150,7 +159,7 @@ print < > align=3D"left"> > sans-serif" color=3D"#666666" size=3D"2"> > - $tr{'advproxy chgwebpwd new > password'}: > + $Lang::tr{'advproxy chgwebpwd new > password'}: > > > name=3D"NEW_PASSWORD_1" value=3D"$cgiparams{'NEW_PASSWORD_1'}" size=3D"30">= > @@ -158,7 +167,7 @@ print < > align=3D"left"> > sans-serif" color=3D"#666666" size=3D"2"> > - $tr{'advproxy chgwebpwd new > password confirm'}: > + $Lang::tr{'advproxy chgwebpwd new > password confirm'}: > > > name=3D"NEW_PASSWORD_2" value=3D"$cgiparams{'NEW_PASSWORD_2'}" size=3D"30">= > @@ -166,7 +175,7 @@ print < > cellpadding=3D"7"> > > - > + > >

type=3D'submit' name=3D'SUBMIT' value=3D"$tr{'advproxy chgwebpwd change > password'}">

type=3D'submit' name=3D'SUBMIT' value=3D"$Lang::tr{'advproxy chgwebpwd chan= ge > password'}">
> > @@ -180,7 +189,7 @@ if ($errormessage) > > > color=3D"#FFFFFF" size=3D"2"> > - $tr{'advproxy chgwebpwd ERROR'} $errormessage > + $Lang::tr{'advproxy chgwebpwd ERROR'} $errormessage > > > > @@ -194,7 +203,7 @@ if ($success) > > > color=3D"#FFFFFF" size=3D"2"> > - $tr{'advproxy chgwebpwd SUCCESS'} $tr{'advproxy errmsg > change success'} > + $Lang::tr{'advproxy chgwebpwd SUCCESS'} > $Lang::tr{'advproxy errmsg change success'} > > > --===============9163073170971008103== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUFCQ2dBZEZpRUU1L3JXNWwzR0dl Mnlwa3R4Z0hudy8yK1FDUWNGQWxuVkEyc0FDZ2tRZ0hudy8yK1EKQ1FjN093LytQRS9UV2ZWNWND ZGswNXNQZDRJTlpuT2xndEJGbEFrcEVITk1QU3BRdTJneWxzTGVzVmRibTZzaAo2RGFDaFZpd2Vn bFN1RXMrRFNnRGw2ZmxVcGF2ZzFvSHc3Rm1NS0phUHZobThPVm9CcVFWbUJHRDFoMzJYUGxjCnpk WGZrdXdKM2hHbWpaSzlTWVZGS2J6S3dPbENWOTFGdXA0dUhsYi9EZ3FXaXk5bkNNQlo1NUV4N01W MGdWWEkKN01LQ3FvbTV2ckU3R2UyQ2ZreXdaWGRSQ01hMDdxTzgwNk5kWVo5VmovNEJYUWwvWWJO anZQeldEVmNBTkRBVgpLZnJyODBLNDFsZFFzNGJjcnlCTlRyNFFtSVlkL3prSjZJclM0T1o3R3U5 MzFSQnpaU3ZSWjJoWjRiZnhrd1BFCkRqT0hiSzZMd0JXZWtrZ0RrS3VhYUk1QVNnYk03VTZ6YTVU MU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